实验名称最小二乘逼近实验目的和 要 求1 掌握最小二乘逼近的的基本思路和步骤2 培养使用matlab 软件编程及上机调试能力实验内容和步骤:实验内容:用最小逼近法计算以下3 题:1、Given the table Xi -2 -1 0 1 2 Yi -0.1 0.1 0.4 0.9 1.6 Solve a quadratic and cubic fitting functions respectively with the least squares method 2、Find the least squares polynomials of degree1,2and 3 for the data in the following table. Compute the error in each case .Graph the data and the polynomials. Xi 1.0 1.1 1.3 1.5 1.9 2.1 Yi 1.84 1.96 2.21 2.45 2.94 3.18 3、Given the data: Xi 4.0 4.2 4.5 4.7 5.1 5.5 5.9 6.3 6.8 7.1 Yi 102.56 113.18 130.11 142.05 167.53 195.14 224.87 256.73 299.50 326.72 (1) Construct the least squares polynomials of degree 1,2and 3, and compute the errors. (2)Construct the least squares approximation of the form beax, and compute the errors 试验步骤:1)实验编程2)运行结果实验过程1、Given the table Xi -2 -1 0 1 2 Yi -0.1 0.1 0.4 0.9 1.6 Solve a quadratic and cubic fitting functions respectively with the least squares method 解:>> x=[-2 -1 0 1 2 ]; y=[-0.1 0.1 0.4 0.9 1.6]; plot(x,y,'r*'), legend(' 数据点 (xi,yi)') >> a=polyfit(x,y,2) a = 0.0857 0.4200 0.4086 >> a=polyfit(x,y,3) a = 0.0083 0.0857 0.3917 0.4086 2、Find the least squares polynomials of degree1,2and 3 for the data in the following table. Compute the error in each case .Graph the data and the polynomials. Xi 1.0 1.1 1.3 1.5 1.9 2.1 Yi 1.84 1.96 2.21 2.45 2.94 3.18 解:>>x=[1.0 1.1 1.3 1.5 1.9 2.1]; y=[1.84 1.96 2.21 2.45 2.94 3.18]; plot(x,y,'r*'), legend(' 数据点 (xi,yi)') >> a=polyfit(x,y,1) a = 1.2196 0.6209 >> a=polyfit(x,y,2) a = -0.0109 1.2533 0.5966 a=polyfit(x,y,3) a = -0.0100 0.0353 1.1850 0.6290 >> x=[1.0 1.1 1.3 1.5 1.9 2.1]; y=[1.84 1....