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
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
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.