Example: a cubic regression of a 6-point {(x,yDi=1:6 problem, using the polynomial coefficients a= [ 3.0000 2.0000 -1.00
Posted: Mon May 16, 2022 6:27 am
Example: a cubic regression of a 6-point {(x,yDi=1:6 problem, using the polynomial coefficients a= [ 3.0000 2.0000 -1.0000 5.0000] х -1.0000 1.2000 1.6000 3.5000 5.5000 6.0000 у ym=y+noise 5.0000 5.3376 11.8640 12.8641 20.8080 19.1438 154.6250 154.0350 559.1250 558.8469 719.0000 719.4227 % Two step least-error-estimation of the cubic polynomial % regression by eqs. (2) and (3). A=[x. 3 x. 2 x ones (6,1)); z=(A'*A) \A'*ym; % z=[ 3.0265 1.8882 -1.2637 5.2693] % this estimate is based on some noise-randn(6, 1) embedded in ym. X3=linspace(-2,7,200); P3-polyfit(x,ym,3); % get cubic poly. coefficient estimate $ note that this P3=2 y3-polyval (P3, 3); figure;plot(x,ym,'o',X3,3); grid
a. Find the interpolating polynomial over the given 6-point data set. b. Show the matrix A, z and P5=polyfit(x, ym, 5) c. Interpolate the output at x = 2.7, i.e. show p(2.7). Try: yhat = polyval(P5, 2.7) d. Show plot of (x, ym, 'o') and (x,y) from this interpolation, where x=linspace(-2,7,100) and y = p(x)
a. Find the interpolating polynomial over the given 6-point data set. b. Show the matrix A, z and P5=polyfit(x, ym, 5) c. Interpolate the output at x = 2.7, i.e. show p(2.7). Try: yhat = polyval(P5, 2.7) d. Show plot of (x, ym, 'o') and (x,y) from this interpolation, where x=linspace(-2,7,100) and y = p(x)