strColor = {'-r','-g','-b'};
strLegend = {'nSamples = 5','nSamples = 10','nSamples = 15'};
for k = 1:length(n)
newX = linspace(xpts(1),xpts(end),n(k));
subplot(1,3,k);
hold on
p = interp1(xpts,ypts,newX,'spline');
p2 = plot(xpts,ypts,'ko','MarkerFaceColor','k','MarkerSize',4);
hold on
p3 = plot(newX,p,strColor{k});
hold on
legend([p p2 p3], {'Data', 'something', strLegend(k)});
title('Plotting with polyfit and polyval');
end
0 Comments
Sign in to comment.