Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

HELP ME WITH THE MATLAB PROBLEMS! Plot the points in data1 using the o linespec

ID: 3566451 • Letter: H

Question

HELP ME WITH THE MATLAB PROBLEMS!

Plot the points in data1 using the o linespec command so that Matlab doesnt
connect the points. Fit the following curves to the data, using polyfit:

Answers: Should be written out as A1-A3.dat.

HELP ME WITH THE MATLAB PROBLEMS! data1 = [-2:2; 44.0000 6.0865 2.0612 8.0989 48.0527]; Plot the points in data1 using the ½o½ linespec command so that Matlab doesn½t connect the points. Fit the following curves to the data, using polyfit: Jth column. Answers: Should be written out as A1-A3.dat. Cj in the Note that you may get some warnings about the polynomial degree (especially when the degree is greater than N ?1). Plot the three curves using polyval along with the data (can use x = -2:0.01:2 ). For each curve, store the coefficients as a row vector with

Explanation / Answer

data1 = [44.0000 6.0865 2.0612 8.0989 48.0527];
plot(-2:2,data1,'o');
hold on;
A1 = polyfit(-2:2,data1,2);
A2 = polyfit(-2:2,data1,4);
A3 = polyfit(-2:2,data1,6);
plot(-2:.01:2,polyval(A1,[-2:.01:2]));
plot(-2:.01:2,polyval(A2,[-2:.01:2]));
plot(-2:.01:2,polyval(A3,[-2:.01:2]));