MATLAB上机实验练习题及答案

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

09级MATLAB上机实验练习题1、给出一个系数矩阵A[234;541;132],U=[123],求出线性方程组的一个精确解。2、给出两组数据x=[00.30.81.11.62.3]’y=[0.820.720.630.600.550.50]’,我们可以简单的认为这组数据在一条衰减的指数函数曲线上,y=C1+C2e-t通过曲线拟合求出这条衰减曲线的表达式,并且在图形窗口画出这条曲线,已知的点用*表示。3、解线性方程4、通过测量得到一组数据:5、已知一组测量值6、从某一个过程中通过测量得到:分别采用多项式和指数函数进行曲线拟合。7、将一个窗口分成四个子窗口,分别用四种方法做出多峰函数的表面图(原始数据法,临近插值法,双线性插值法,二重三次方插值法)8、在同一窗口使用函数作图的方法绘出正弦、余弦、双曲正弦、双曲余弦。分别使用不同的颜色,线形和标识符。9、下面的矩阵X表示三种产品五年内的销售额,用函数pie显示每种产品在五年内的销售额占总销售额的比例,并分离第三种产品的切片。X=19.322.151.634.270.382.461.482.990.850.554.959.129.436.347.010、对应时间矢量t,测得一组矢量yt00.30.81.11.62.3y0.50.821.141.251.351.40采用一个带有线性参数的指数函数进行拟合,y=a0+a1e-t+a2te-t,利用回归方法求出拟合函数,并画出拟合曲线,已知点用圆点表示。11、请创建如图所示的结构数组(9分)姓名编号指标江明顺071023身高:176,体重:82于越忠060134身高:168,体重:74邓拓050839身高:182,体重:7712、创建如图所示的元胞数组。(9分)13、某钢材厂从1990年到2010年的产量如下表所示,请利用三次样条插值的方法计算1999年该钢材厂的产量,并画出曲线,已知数据用‘*’表示。要求写出达到题目要求的MATLAB操作过程,不要求计算结果。年份19901992199419961998200020022004200620082010产量(万吨)75.99591.972105.711123.203131.669150.697179.323203.212226.505249.633256.34414、在一次化学动力学实验中,在某温度下乙醇溶液中,两种化合物反应的产物浓度与反应时间关系的原始数据如下,请对这组数据进行三次多项式拟合,并画出拟合曲线,已知数据如下。time=[2.55.07.510.013.017.020.030.040.050.060.070.0]res=[0.290.560.771.051.361.522.002.272.813.053.253.56]15、请在-2x2,-2y2的范围内绘制出函数22yxxez形成的曲面网线图。16、请在同一窗口画出两条曲线,y1=sin(x),y2=cos(x),要求添加网格线,x轴标注IndependentVariableX,y轴标注DependentVariableY1&Y2,标注标题SineandCosineCurve,在(1.5,0.3)处标注cos(x),坐标轴设定在x轴[0,2Π],y轴[-0.9,0.9]。答案1、A=[234;541;132];U=[123]';X=A\UX=-0.81481.6667-0.59262、t=[00.30.81.11.62.3]';y=[0.820.720.630.600.550.50]';E=[ones(size(t))exp(-t)];C=E\yC=0.47600.3413x=0:0.01:2.5;z=0.4760+0.3413*exp(-x);plot(t,y,'O',x,z,'r:')00.511.522.50.50.550.60.650.70.750.80.850.93、A=[3105;0-673;0430;2-126];Y=[2478]';X=A\YX=-4.82471.39440.47413.01594、t=[12345678910]';y=[4.8424.3623.7543.3683.1693.0833.0343.0163.0123.005]';E1=[ones(size(t))exp(-t)];C=E1\yC=3.16215.1961E2=[ones(size(t))t.*exp(-t)];D=E2\yD=3.00395.0046x=1:0.01:10;y1=3.1621+5.1961*exp(-x);y2=3.0039+5.0046*x.*exp(-x);plot(t,y,'O',x,y1,'r:',x,y2,'b-')1234567891033.544.555.5p1=polyfit(t,y,2)p1=0.0411-0.63835.3937p2=polyfit(t,y,3)p2=-0.00410.1085-0.94935.7443y3=polyval(p1,x);y4=polyval(p2,x);plot(t,y,'O',x,y3,'r:',x,y4,'b-')123456789102.533.544.556、t=[00.20.40.60.81.02.05.0]';y=[1.01.511.882.132.292.402.60-4.00]';p=polyfit(t,y,4)p=-0.09930.7935-2.28412.98820.9995E=[ones(size(t))exp(-t)];C=E\yC=-0.05652.5674x=0:0.001:5;y1=-0.0565+2.5674*exp(-x);y2=polyval(p,x);plot(t,y,'O',x,y1,'r:',x,y2,'b-')00.511.522.533.544.55-5-4-3-2-101237、•001functioncompare_interp()•002%COMPARE_INTERP不同插值运算的比较•003•004%原始数据•005[x,y]=meshgrid(?3:1:3);•006z=peaks(x,y);•007figure(1);clf•008surfc(x,y,z);•009title('原始数据')•010%进行插值运算•011[xi,yi]=meshgrid(?3:0.25:3);•012zi1=interp2(x,y,z,xi,yi,'nearest');•013zi2=interp2(x,y,z,xi,yi,'linear');•014zi3=interp2(x,y,z,xi,yi,'cubic');•015zi4=interp2(x,y,z,xi,yi,'spline');•016%通过可视化结果比较•017figure(2)•018subplot(2,2,1);surf(xi,yi,zi1);•019title('二维插值-''nearest''')•020subplot(2,2,2);surf(xi,yi,zi2);•021title('二维插值-''linear''')•022subplot(2,2,3);surf(xi,yi,zi3)•023title('二维插值-''cubic''')•024subplot(2,2,4);surf(xi,yi,zi4)•025title('二维插值-''spline''')•026%可视化结果•027figure(3)•028subplot(2,2,1);contour(xi,yi,zi1)•029title('二维插值-''nearest''')•030subplot(2,2,2);contour(xi,yi,zi2)•031title('二维插值-''linear''')•032subplot(2,2,3);contour(xi,yi,zi3)•033title('二维插值-''cubic''')•034subplot(2,2,4);contour(xi,yi,zi4)•035title('二维插值-''spline'''')•8、x=-pi:pi/4:pi;y1=sin(x);-505-505-10010二维插值-'nearest'-505-505-10010二维插值-'linear'-505-505-10010二维插值-'cubic'-505-505-10010二维插值-'spline'-4-2024-4-2024-6-4-20246原始数据y2=cos(x);y3=sinh(x);y4=cosh(x);plot(x,y1,'rO:',x,y2,'b*-',x,y3,'gs--',x,y4,'k^-.')-4-3-2-101234-15-10-50510159、X=[19.322.151.6;34.270.382.4;61.482.990.8;50.554.959.1;29.439.347];x=sum(X)x=194.8000269.5000330.9000explode=[001];pie(x,explode)24%34%42%10、t=[00.30.81.11.62.3]';y=[0.50.821.141.251.351.40]';E=[ones(size(t))exp(-t)t.*exp(-t)]E=1.00001.000001.00000.74080.22221.00000.44930.35951.00000.33290.36621.00000.20190.32301.00000.10030.2306A=E\yA=1.3974-0.89880.4097x=0:0.01:2.5;Y=1.3974-0.8988*exp(-x)+0.4097*x.*exp(-x);plot(t,y,'O',x,Y,'r-')00.511.522.50.40.60.811.21.41.611、A=struct('name',{'江明顺','于越忠','邓拓'},'NO',{'071023','060134','050839'});A(1).level=struct('height','176','weight','82')A=1x3structarraywithfields:nameNOlevelA(2).level=struct('height','168','weight','74')A=1x3structarraywithfields:nameNOlevelA(3).level=struct('height','182','weight','77')A=1x3structarraywithfields:nameNOlevel12、B=cell(1,2);B{1,1}=struct('date','2007/06/04','billing',[125.7389.3;254.9538.5])B=[1x1struct][]B{1,2}=struct('name','maggie','profession','teacher','hobby','dance')B=[1x1struct][1x1struct]cellplot(B)13、year=1990:2:2010;product=[75.99591.972105.711123.203131.669150.697179.323203.212226.505249.633256.344];p1999=interp1(year,product,1999,’spline’)x=1990:1:2010;y=interp1(year,product,x,'spline');plot(year,product,'*',x,y)14、X=[

1 / 12
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功