x=[1 2 3 4 5 6];y=[2 4 6 8 10 12];plot(x,y)fun=inline('a(1)+a(2)*x','a','x'); b=rand(1,2);a=lsqcurvefit(fun,b,x,y)a = 0.0000 2.0000即:y=2x
用数据拟合函数就好了x=[1 2 3 4 5 6];y=[2 4 6 8 10 12];p=polyval(x,y)