image.png
x=[-1.2 -1.5 0.3 0.9 1.8 2.6 3.0 3.5 5.0 8.0];
y=[-15.6 -8.5 2.2 4.5 6.6 8.2 8.9 10.0 13.2 19.4];
figure('Position',[50 50 1500 400]);
for i=1:3
subplot(1,3,i);
p = polyfit(x,y,i);
xfit=x(1):0.1:x(end);
yfit= polyval(p,xfit);
plot(x,y,'ro',xfit,yfit);
set(gca,'Fontsize',14);
ylim([-17, 11]);
legend(4,'Data points','Fitted curve');
end