数模第八次上机作业_第1页
数模第八次上机作业_第2页
数模第八次上机作业_第3页
数模第八次上机作业_第4页
数模第八次上机作业_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

西安文理学院数学系 数学建模实验 数学建模实验报告实验课程:数学建模 实验时间: 2012-6-11 任课教师:张力宁 班级:信息班 姓名: 学号:02 一、实验名称: 数据的最小二乘逼近 二、实验目的:1、了解插值的基本原理和方法;2、掌握用MATLAB计算线性和非线性最小二乘逼近;三、实验要求:1. 在D盘建立一个自己的文件夹;2能够掌握数据的插值与拟合的数学原理及基本方法; 3学会利用MATLAB软件对数据进行拟合,并进行误差分析;4将你输入的命令、程序及运行结果保存在word文件中,作为作业提交; 5若出现错误,修改、运行直到输出正确结果; 四、报告正文(文挡,数据,模型,程序,图形):1、 测得铜导线在温度()时的电阻如下表,设R与T之间满足线性关系,试对下表中的数据进行最小二乘逼近,并将拟合值与测量值进行比较,计算各测量温度时的绝对误差和相对误差并绘制拟合曲线。()19.125.030.136.040.045.150.076.3077.8079.2580.8082.3583.9085.10 x=19.1 25.0 30.1 36.0 40.0 45.1 50.0;y=76.30 77.80 79.25 80.80 82.35 83.90 85.10;plot(x,y,*)f1=polyfit(x,y,1)y1=polyval(f1,x);plot(x,y,ko,x,y1,m-)title(铜导线在温度T时的电阻R)xlabel(T/)ylabel(R/)f1 = 0.2915 70.5723相对误差与绝对误差: jdwc=abs(y1-y)xdwc=jdwc./yjdwc = Columns 1 through 6 0.1609 0.0587 0.0951 0.2647 0.1195 0.1831 Column 7 0.0451xdwc = Columns 1 through 6 0.0021 0.0008 0.0012 0.0033 0.0015 0.0022 Column 7 0.00052、用给定的多项式上产生一组数据(xi, yi,i=1,2,21),其中横坐标向量为10:1:10。然后在yi上添加随机干扰(可用rand产生(0,1)均匀分布随机数, 或用rands产生N(0,1)分布随机数),然后对数据点 i=1,2,21作3次多项式拟合,与原系数比较。如果作2或4次多项式拟合,结果又如何? 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);plot(x,y,+,x,y1) grid on title(一次拟合曲线); figure(2); f2=polyfit(x,y0,2)y2=polyval(f2,x); plot(x,y,+,x,y2); grid on title(二次拟合曲线); figure(3); f4=polyfit(x,y0,4)y3=polyval(f4,x); plot(x,y,+,x,y3) grid on title(四次拟合曲线); figure(4); f6=polyfit(x,y0,6)y4=polyval(f6,x); plot(x,y,+,x,y4) grid on title(六次拟合曲线); f1 = 43.2000 -148.7173f2 = 10.5000 -72.3000 90.1577f4 = -0.0000 1.0000 -6.0000 5.0000 -2.2423f6 = Columns 1 through 6 -0.0000 0.0000 -0.0000 1.0000 -6.0000 5.0000 Column 7 -2.2423 3、将17至29岁的运动员每两岁分为一组,在每组中测量一名运动员测量其旋转定向能力,数据如下表所示,年龄17192123252729旋转定向能力20.4825.1326.153026.120.319.35试以年龄为横坐标,旋转定向能力为纵坐标描绘上述表格中数据的散点图,并根据其变化趋势选择适当的模型对其进行最小二乘逼近,建立旋转定向能力与年龄之间关系的数学模型并绘制拟合曲线 x=17:2:29;y=20.48 25.13 26.15 30 26.1 20.3 19.35;plot(x,y,*)f2=polyfit(x,y,7)x2=17:1:29;y2=polyval(f2,x2);plot(x,y,ko,x2,y2,m-)title(运动员及其旋转定向能力)xlabel(年龄)ylabel(旋转定向能力)Warning: Polynomial is not unique; degree = number of datapoints. In polyfit at 71f2 = 1.0e+003 * Columns 1 through 6 -0.0000 0.0000 -0.0004 0.0125 -0.2138 1.9350 Columns 7 through 8 -7.2395 04、给定数据如下:求的最小二乘逼近曲线.并绘制拟合曲线function f=curvefun1(x,tdata)f=x(1)*exp(-x(2)*tdata) x=-10:1:10x = Columns 1 through 9 -10 -9 -8 -7 -6 -5 -4 -3 -2 Columns 10 through 18 -1 0 1 2 3 4 5 6 7 Columns 19 through 21 8 9 10 tdata=1:0.25:2tdata = 1.0000 1.2500 1.5000 1.7500 2.0000 cdata=1e-03*5.10,5.79,6.53,7.45,8.46cdata = 0.0051 0.0058 0.0065 0.0075 0.0085 x0=0.2,0.05x0 = 0.2000 0.0500 x=lsqcurvefit(curvefun1,x0,tdata,cdata)f = 0.1902 0.1879 0.1855 0.1832 0.1810f = 0.1902 0.1879 0.1855 0.1832 0.1810f = 0.1902 0.1879 0.1855 0.1832 0.1810f = 0.1902 0.1879 0.1855 0.1832 0.1810f = 0.0012 0.0012 0.0012 0.0012 0.0012f = 0.0012 0.0012 0.0012 0.0012 0.0012f = 0.0012 0.0012 0.0012 0.0012 0.0012f = 0.0012 0.0012 0.0012 0.0012 0.0012f = 0.0263 0.0547 0.1135 0.2357 0.4895f = 0.0263 0.0547 0.1135 0.2357 0.4895f = 0.0263 0.0547 0.1135 0.2357 0.4895f = 0.0263 0.0547 0.1135 0.2357 0.4895f = 0.0113 0.0135 0.0161 0.0192 0.0230f = 0.0113 0.0135 0.0161 0.0192 0.0230f = 0.0113 0.0135 0.0161 0.0192 0.0230f = 0.0113 0.0135 0.0161 0.0192 0.0230f = 0.0077 0.0080 0.0083 0.0087 0.0090f = 0.0077 0.0080 0.0083 0.0087 0.0090f = 0.0077 0.0080 0.0083 0.0087 0.0090f = 0.0077 0.0080 0.0083 0.0087 0.0090f = 0.0038 0.0042 0.0047 0.0053 0.0059f = 0.0038 0.0042 0.0047 0.0053 0.0059f = 0.0038 0.0042 0.0047 0.0053 0.0059f = 0.0038 0.0042 0.0047 0.0053 0.0059f = 0.0058 0.0061 0.0064 0.0068 0.0072f = 0.0058 0.0061 0.0064 0.0068 0.0072f = 0.0058 0.0061 0.0064 0.0068 0.0072f = 0.0058 0.0061 0.0064 0.0068 0.0072f = 0.0054 0.0060 0.0065 0.0072 0.0078f = 0.0054 0.0060 0.0065 0.0072 0.0078f = 0.0054 0.0060 0.0065 0.0072 0.0078f = 0.0054 0.0060 0.0065 0.0072 0.0078f = 0.0050 0.0056 0.0064 0.0073 0.0083f = 0.0050 0.0056 0.0064 0.0073 0.0083f = 0.0050 0.0056 0.0064 0.0073 0.0083f = 0.0050 0.0056 0.0064 0.0073 0.0083Optimization terminated successfully: Relative function value changing by less than OPTIONS.TolFunx = 0.0030 -0.5082 0.0500 f=curvefun1(x,tdata)f = 0.0050 0.0056 0.0064 0.0073 0.0083f =0.0050 0.0056 0.0064 0.0073 0.0083 ezplot(0.0030*exp(0.5082*t)5、给出美国人口从1790年到1980年间的人口如下表(每10年为一个间隔),请估计出美国2010年的人口。表1 美国人口统计数据年 份1790180018101820183018401850人口(106)3.95.37.29.612.917.123.2年 份1860187018801890190019101920人口(106)31.438.650.262.976.092.0106.5年 份193019401950196019701980人口(106)123.2131.7150.7179.3204.0226.5(1)设模型1为指数增长模型:f(t)=ea+bt,a,b为待定常数,试通过最小二乘逼近的方法拟合出参数a、b。 tdata=1790:10:1980tdata = Columns 1 through 4 1790 1800 1810 1820 Columns 5 through 8 1830 1840 1850 1860 Columns 9 through 12 1870 1880 1890 1900 Columns 13 through 16 1910 1920 1930 1940 Columns 17 through 20 1950 1960 1970 1980 cdata=1e-03*3.9,5.3,7.2,9.6,12.9,17.1,23.2,31.4,38.6,50.2,62.9,76.0,92.0,106.5,123.2,131.7,150.7,179.3,204.0,226.5cdata = Columns 1 through 5 0.0039 0.0053 0.0072 0.0096 0.0129 Columns 6 through 10 0.0171 0.0232 0.0314 0.0386 0.0502 Columns 11 through 15 0.0629 0.0760 0.0920 0.1065 0.1232 Columns 16 through 20 0.1317 0.1507 0.1793 0.2040 0.2265 x0=0.2,0.05x0 =0.2000 0.0500 x=lsqcurvefit(curvefun1,x0,tdata,cdata)f = 1.0e-038 * Columns 1 through 5 0.1106 0.0671 0.0407 0.0247 0.0150 Columns 6 through 10 0.0091 0.0055 0.0033 0.0020 0.0012 Columns 11 through 15 0.0007 0.0005 0.0003 0.0002 0.0001 Columns 16 through 20 0.0001 0.0000 0.0000 0.0000 0.0000f = 1.0e-038 * Columns 1 through 5 0.1106 0.0671 0.0407 0.0247 0.0150 Columns 6 through 10 0.0091 0.0055 0.0033 0.0020 0.0012 Columns 11 through 15 0.0007 0.0005 0.0003 0.0002 0.0001 Columns 16 through 20 0.0001 0.0000 0.0000 0.0000 0.0000f = 1.0e-038 * Columns 1 through 5 0.1106 0.0671 0.0407 0.0247 0.0150 Columns 6 through 10 0.0091 0.0055 0.0033 0.0020 0.0012 Columns 11 through 15 0.0007 0.0005 0.0003 0.0002 0.0001 Columns 16 through 20 0.0001 0.0000 0.0000 0.0000 0.0000f = 1.0e-038 * Columns 1 through 5 0.1106 0.0671 0.0407 0.0247 0.0150 Columns 6 through 10 0.0091 0.0055 0.0033 0.0020 0.0012 Columns 11 through 15 0.0007 0.0005 0.0003 0.0002 0.0001 Columns 16 through 20 0.0001 0.0000 0.0000 0.0000 0.0000Optimization terminated successfully: First-order optimality less than OPTIONS.TolFun, and no negative/zero curvature detectedx = 0.2000 0.0500 f=curvefun1(x,tdata)f = 1.0e-038 * Columns 1 through 5 0.1106 0.0671 0.0407 0.0247 0.0150 Columns 6 through 10 0.0091 0.0055 0.0033 0.0020 0.0012 Columns 11 through 15 0.0007 0.0005 0.0003 0.0002 0.0001 Columns 16 through 20 0.0001 0.

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论