资源描述
【精品文档】如有侵权,请联系网站删除,仅供学习与交流数学建模第四版第七章课后答案.精品文档.第七章第一题clc%数据输入x=68 68 87 87 106 106 140 140;y=9.7981 13.324 9.0078 13.355 9.7918 14.277 9.6563 12.463;z=0.0848 0.0897 0.0762 0.0807 0.0696 0.0753 0.0611 0.0651;%插值cx=99;cy=10.3;cz=griddata(x,y,z,cx,cy,cubic)%做表面图%meshz(cx,cy,cz)cz =0.0724第二题x=129 140 103.5 88 185.5 195 105.5 157.5 107.5 77 81 162 162 117.5;y=7.5 141.5 23 147 22.5 137.5 85.5 -6.5 -81 3 56.5 -66.5 84 -33.5;z=4 8 6 8 6 8 8 9 9 8 8 9 4 9;%插值cx=75:0.5:200;cy=-50:0.5:150;cz=griddata(x,y,z,cx,cy,cubic)4.7984 4.7554 4.7129 4.6711 4.6299 4.5893 4.5494 4.5102 4.4718 4.4341 4.8239 4.7808 4.7383 4.6963 4.6550 4.6142 4.5742 4.5348 4.4962 4.4583 4.8492 4.8061 4.7635 4.7214 4.6800 4.6391 4.5990 4.5594 4.5206 4.4825 4.8744 4.8312 4.7885 4.7464 4.7049 4.6639 4.6236 4.5840 4.5450 4.5067 4.8992 4.8560 4.8133 4.7711 4.7295 4.6885 4.6481 4.6084 4.5693 4.5309 4.9237 4.8805 4.8378 4.7956 4.7539 4.7129 4.6724 4.6326 4.5934 4.5549 4.9478 4.9046 4.8619 4.8197 4.7780 4.7369 4.6964 4.6565 4.6172 4.5786 4.9715 4.9283 4.8856 4.8433 4.8016 4.7605 4.7200 4.6800 4.6407 4.6021 4.9946 4.9514 4.9087 4.8665 4.8248 4.7837 4.7431 4.7031 4.6638 4.6251 5.0172 4.9740 4.9313 4.8891 4.8474 4.8063 4.7657 4.7257 4.6864 4.6476 5.0391 4.9960 4.9533 4.9111 4.8694 4.8283 4.7877 4.7477 4.7083 4.6696 5.0603 5.0172 4.9745 4.9324 4.8907 4.8496 4.8090 4.7690 4.7296 4.6908 5.0808 5.0377 4.9950 4.9528 4.9112 4.8701 4.8295 4.7895 4.7501 4.7114 5.1003 5.0573 5.0146 4.9725 4.9309 4.8897 4.8492 4.8092 4.7698 4.7310 5.1190 5.0759 5.0333 4.9912 4.9496 4.9085 4.8679 4.8279 4.7886 4.7498 5.1367 5.0936 5.0510 5.0089 4.9673 4.9262 4.8856 4.8457 4.8063 4.7675 5.1533 5.1102 5.0676 5.0255 4.9839 4.9428 4.9022 4.8622 4.8228 4.7841 5.1688 5.1257 5.0831 5.0410 4.9993 4.9582 4.9176 4.8776 4.8382 4.7994 5.1830 5.1399 5.0973 5.0551 5.0135 4.9723 4.9317 4.8917 4.8522 4.8134 5.1967 5.1536 5.1110 5.0688 5.0272 4.9860 4.9454 4.9054 4.8660 4.8272 5.2110 5.1679 5.1253 5.0832 5.0415 5.0004 4.9598 4.9198 4.8804 4.8416 5.2260 5.1829 5.1403 5.0982 5.0565 5.0154 4.9748 4.9348 4.8954 4.8566 5.2416 5.1985 5.1559 5.1138 5.0721 5.0310 4.9904 4.9504 4.9110 4.8721 5.2578 5.2147 5.1721 5.1300 5.0883 5.0472 5.0066 4.9666 4.9271 4.8883 5.2746 5.2315 5.1889 5.1467 5.1051 5.0639 5.0233 4.9833 4.9438 4.9050 5.2920 5.2489 5.2062 5.1641 5.1224 5.0812 5.0406 5.0005 4.9610 4.9222 5.3099 5.2668 5.2241 5.1819 5.1402 5.0990 5.0584 5.0183 4.9788 4.9399 5.3283 5.2852 5.2425 5.2003 5.1586 5.1173 5.0767 5.0366 4.9970 4.9581 5.3473 5.3041 5.2614 5.2191 5.1774 5.1361 5.0954 5.0553 5.0157 4.97第三题x=1:0.5:10; y=x.3-6*x.2+5*x-3;y0=y+rand; f1=polyfit(x,y0,1)%输出多项式系数y1=polyval(f1,x);%计算各x点的拟合值plot(x,y,+,x,y1)gridon title(一次拟合曲线);figure(2); f2=polyfit(x,y0,2)%2次多项式拟合y2=polyval(f2,x);plot(x,y,+,x,y2); gridon title(二次拟合曲);figure(3); f4=polyfit(x,y0,4)%4次多项式拟合y3=polyval(f4,x);plot(x,y,+,x,y3)gridon title(四次拟合曲线);figure(4); f6=polyfit(x,y0,6)%6次多项式拟合y4=polyval(f6,x);plot(x,y,+,x,y4)gridon title(六次拟合曲线); 运行结果如下:依次为各个拟合曲线的系数(按降幂排列)f1=43.2000-149.0663 f2=10.5000-72.300089.8087 f4=0.00001.0000-6.00005.0000-2.5913 f6=0.0000-0.00000.00001.0000-6.00005.0000-2.4199运行后,比较拟合后多项式和原式的系数,发现四次多项式系数与原系数比较接近,四次多项式的四次项系数很小。作图后,发现一次和二次多项式的图形与原函数的差别比较大,属于欠拟合的情况,而四次多项式和六次多项式符合得比较好。第四题clctdata=0.5,1,2,3,4,5,7,9;cdata=1e-03*6.36,6.48,7.26,8.22,8.66,8.99,9.43,9.63;x0=0.2,0.05,0.05;x=lsqcurvefit(curvefun1,x0,tdata,cdata)f=curvefun1(x,tdata)第五题x=1247912131517; y=1.53.96.611.715.618.819.620.621.1x1=x(1:5);y1=y(1:5); p1=polyfit(x1999999,y115.615.615.615.615.615.6,1);xx1=linspace(x(1),x(5),50);yy1=polyval(p1,xx1);x2=x(5:9);y2=y(5:9); p2=polyfit(x29,y215.6,2);F2=poly2str(p2,x) xx2=linspace(x(5),x(9),50);yy2=polyval(p2,xx2); plot(x,y,o,xx1,yy1,xx2,yy2)F2= -0.076488x2+2.6745x-2.273
展开阅读全文