I'm trying to plot the same data multiple times but with a different degree of curve each time. Every time I try, the code runs through fine, but my plot does not show any line fit at all, it just shows my data points.
here is my current code.
X =
NaN
0.2200
0.3000
0.4400
0.4900
0.7000
0.8000
0.9000
1.1000
1.0000
1.1500
1.2000
1.2200
1.2600
1.2500
1.2700
1.2000
1.2200
1.2600
1.2000
1.2200
1.2600
1.2000
1.2200
1.2600
1.2500
t =
NaN
0
4
7
10
13
16
22
25
30
33
36
40
48
51
55
60
80
100
120
140
160
180
200
220
240
x=(t);
y6=(X);
% First Degree
subplot(1,3,1);
p=polyfit(x,y6,1);
f=polyval(p,x);
plot(x,y6,'o',x,f,'r-')
legend('data','linear fit')
% Second Degree
subplot(1,3,2);
p=polyfit(x,y6,2)
f=polyval(p,x)
plot(x,y6,'o',x,f,'r-')
% Third Degree
subplot(1,3,3);
p=polyfit(x,y6,3)
f=polyval(p,x)
plot(x,y6,'o',x,f,'r')