实验名称最小二乘逼近实验目的和要求1掌握最小二乘逼近的的基本思路和步骤2培养使用matlab软件编程及上机调试能力实验内容和步骤:实验内容:用最小逼近法计算以下3题:1、GiventhetableXi-2-1012Yi-、Findtheleastsquarespolynomialsofdegree1,、Giventhedata:(1)Constructtheleastsquarespolynomialsofdegree1,2and3,putetheerrors.(2)Constructtheleastsquaresapproximationoftheformbeax,putetheerrors试验步骤: 实验编程运行结果实验过程1、GiventhetableXi-2-1012Yi-:>>x=[-2-1012];y=[-];plot(x,y,'r*'),legend('数据点(xi,yi)')>>a=polyfit(x,y,2)a=>>a=polyfit(x,y,3)a=、Findtheleastsquarespolynomialsofdegree1,:>>x=[];y=[];plot(x,y,'r*'),legend('数据点(xi,yi)')>>a=polyfit(x,y,1)a=>>a=polyfit(x,y,2)a=-=polyfit(x,y,3)a=->>x=[];y=[];x1=::;y1=.*x1+;y2=.*x+;w=sum(y2-y)^2;plot(x,y,'r*',x1,y1,'b-');legend('数据点(xi,yi)','拟合曲线y
最小二乘逼近 来自淘豆网www.taodocs.com转载请标明出处.