x=[ 2 4 6 8 ];
y=[2 11 28 40];
plot(x,y,'o');
grid on
hold on
p=polyfit(x,y,1)
x1=0:0.01:9;
y1=polyval(p,x1)
plot(x1,y1,'r')
axis([0 10 0 45])
刚学matlab,请多多指教