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](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/08/6307a2243ac58_6446307a224285b0.jpg)
>>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
To solve this problem you need to find the coefficients of a thirdorder polynomial that best fits th... View full answer
Get step-by-step solutions from verified subject matter experts
