Question: Write a function LeastSquareFit3Pol that solves a linear system of equations to find a least squares fit of a third order polynomial f (x) =

Write a function LeastSquareFit3Pol that solves a linear system of equations to find a least squares fit of a third order polynomial f (x) = a3x3 + a2x2 + aix + ao.r to an experimental data set given as two row arrays. The function LeastSquareFit3Pol must explicitly solve a set of linear equations and cannot use polyfit. For example:

>>x= [-5.0000 -2.5000 >>[a3,a2, a1, a0]=LeastSquareFit3Pol(x,y) a3 = 3.3813 a2 = -4.5143

>>x= [-5.0000 -2.5000 >>[a3,a2, a1, a0]=LeastSquareFit3Pol(x,y) a3 = 3.3813 a2 = -4.5143 a1 = 5.4667 a0 = 7.6286 0 2.5000 5.0000]; y= [-555 -88 Your Function 1 function [a3,a2,a1,a0]=LeastSquareFit3Pol (xdata, ydata) 2 % Least square fit to y(x)=a3x^3+a2x^2+a1x+a0 % Your code goes here 4 5 6 end Save 9. 45 345]; C Reset MATLAB Documentation

Step by Step Solution

3.51 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve this problem you need to find the coefficients of a thirdorder polynomial that best fits th... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!