How Can MATLAB Calculate Polynomial Coefficients for Given Points?

AI Thread Summary
To calculate polynomial coefficients in MATLAB for a quadratic function passing through four points, a user-defined function can be created to accept these points as input. The function will set up and solve a system of four linear equations corresponding to the coefficients a, b, c, and d. The provided example uses the points (-2,-20), (0,4), (2,68), and (4,508), yielding the coefficients a = 7, b = 5, c = -6, and d = 4. A suggestion was made to explore a method similar to a reverse polynomial evaluation to facilitate this calculation. This approach effectively demonstrates how to derive polynomial coefficients from given data points in MATLAB.
George3
Messages
31
Reaction score
0

Homework Statement


`Suppose it is known that the graph of the function y= ax^2 +bx^2+cx+d passes through four given points (x_i,y_i), i = 1,2,3,4. Write a user defined function that accepts these four points as input and computes the coefficients a,b,c and d. The function should solve four linear equations in terms of the four unknowns a,b,c,and d. Test your function for the case where (x_i,y_i) = (-2,-20), (0,4), (2,68), and (4, 508), whose answer is a = 7, b = 5, c = -6, and d = 4.

Homework Equations


The Attempt at a Solution


Is there anything that can do something like a reverse polyval? Any ideas?
 
Last edited:
Physics news on Phys.org
Replace each pair x_i, y_i in the equation. You will have four equations with the unknowns a, b, c, d.
 
Back
Top