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

i couldnt get the file on here so i put the data inside but please write the cod

ID: 2074816 • Letter: I

Question

i couldnt get the file on here so i put the data inside but please write the code as if it was a file.

Data from file:

2.0000 1.5053
12.0000 1.9946
22.0000 2.4740
32.0000 2.7015
42.0000 2.8740
52.0000 2.7615
62.0000 3.0351
72.0000 3.0729
82.0000 3.2623
92.0000 3.2919

The file dataHW6.mat contains experimental data. The first column has >x values and the second column y values. In a properly documented script, perform the following operations: a) Load the data file (use the help to learn how to load a .mat file) b) Plot y vs. x using circles c) Using the polyfit function, fit a model of the following form to your data: y = axb d) Print, using the fprintf function, the values of a and b. e) Overlay the prediction of your model on top of the experimental data. Make sure that your predictions are obtained for at least 1000 points within the range of the provided experimental data. Use a solid line for your model predictions. Make sure your figure contains labels, grids, legends, and that looks good when printed in gray scale

Explanation / Answer

clc
clear all
close all
% a
load dataHW6 x y;
% b
plot(x,y,'o')
hold on
%c
b=2;
c= polyfit(x,y,2);
%d
fprintf('b is %4e and a is %4e ', b, c(:,1));
%e
x2= 0:0.01: x(end);
y2= polyval(c,x2);
plot(x2,y2)
xlabel('x')
ylabel('y')
legend('experimental value', 'predicted value','Location','northwest')
grid on