Alternates of polyval and polyfit?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Manny
el 9 de Mzo. de 2021
Respondida: Walter Roberson
el 9 de Mzo. de 2021
I'm working on an assignment that has to do with interpolating polynomials where I create a picture reading in the data points from a file. However, I am not allowed to use the functions polyfit or polyval. How would I go about finding the coefficients of a polynomial and generating a curve based on those coefficients?
0 comentarios
Respuesta aceptada
Walter Roberson
el 9 de Mzo. de 2021
Suppose you had a polynomial of degree 2, y = a2*x^2 + a1*x^1 + a0*x^0, a2, a1, a0 unknown then you can write that as
[x^2, x^1, x^0] * [a2; a1; a0] = y
Now fill in those values as columns for all known x, y
A = [x1^2, x1, 1
x2^2, x2, 1
x3^2, x3, 1
...]
b = [y1;
y2
y3
...]
and then it follows that
A * [a2; a1; a0] = b
which is a (possibly overdetermined) system of simultaneous linear equations you can solve by your favorite method
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Polynomials en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!