clear all close all %load some data load linefit.dat x=linefit(:,1); y=linefit(:,2); xx=0:.1:7; plot(x,y,'.') %polynomial fits P1=polyfit(x,y,1); %line fit yy=polyval(P1,x); P2=polyfit(x,y,2); %quad fit yy2=polyval(P2,x); P10=polyfit(x,y,10); yy10=polyval(P10,xx); P11=polyfit(x,y,11); yy11=polyval(P11,xx); P14=polyfit(x,y,14); yy14=polyval(P14,xx); hold on %plot(x,yy,'g',xx,yy11,'k') %"connect the dots" interpolation I1=interp1(x,y,xx); plot(xx,I1,'g') I2=interp1(x,y,xx,'nearest'); %step func I3=interp1(x,y,xx,'spline'); %cubic spline plot(xx,I2,'m') plot(xx,I3,'k')