曹加站 20111060255 计算接科学与技术_第1页
曹加站 20111060255 计算接科学与技术_第2页
曹加站 20111060255 计算接科学与技术_第3页
曹加站 20111060255 计算接科学与技术_第4页
曹加站 20111060255 计算接科学与技术_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

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

文档简介

院级选修课云南大学2012-2013学年 下学期 科学计算实践期末考试(上机)试卷满分100分 考试时间:120分钟 任课教师:胡茂学院: 信息学院 专业:计算机科学与技术 学号:20111060255 姓名: 曹加站 题号一二三总分得分一、 基本操作题(本题共7个小题,共25分)1、计算下列各式的值。(3分)(1)(5*2+1.3-0.8)*10/25 (5*2+1.3-0.8)*10./25 ans = 4.2000 (2)(5*2+1.3-0.8)*102/25 (5*2+1.3-0.8)*102./25 ans = 42 (3) sin(10)*exp(-0.3*42)sin(10)*exp(-0.3*42) ans = -0.0045 2、计算的值(3分)(6*tan(0.13*pi)/(sqrt(2)+log(5) ans = 0.8587 3、设 , ,。试求解下列问题。(4分)(1)3a (2)a+b (3)a*d (4)a.b(5)a*c (6)a.*d (7)ab (8)a.b a=2 -1;-2 -2;b=2 -3;0 -4;c=1;2;d=eye(2);y1=3*ay2=a+by3=a*dy4=a.4y5=a*cy6=a.*dy7=aby8=a.b y1 = 6 -3 -6 -6y2 = 4 -4 -2 -6y3 = 2 -1 -2 -2y4 = 16 1 16 16y5 = 0 -6y6 = 2 0 0 -2y7 = 0.6667 -0.3333 -0.6667 2.3333y8 = 1 3 0 2 4、首先生成一个110的随机数组A,然后将它的第5个元素和第8个元素取出,并将它们进行四则运算。(即加减乘除运算)(3分)A=rand(1,10)y1= A(1,5)+A(1,8)5、找出数组中所有绝对值大于3的元素。(2分)A=rand(1,10)y1= A(1,5)+A(1,8)y2= A(1,5)-A(1,8)y3= A(1,5)*A(1,8)y4= A(1,5)./A(1,8) A = 0.0579 0.3529 0.8132 0.0099 0.1389 0.2028 0.1987 0.6038 0.2722 0.1988y1 = 0.7427y2 = -0.4649y3 = 0.0839y4 = 0.2300 6、试用Matlab的inline命令确定函数f=sin2(u)+cos3(v),该u,v为自变量。(5分)syms u vf=sin(2*u)+cos(3*v)y = inline(sin(2*u)+cos(3*v),u,v) f =sin(2*u)+cos(3*v)y = Inline function: y(u,v) = sin(2*u)+cos(3*v) 7、生成3阶随机矩阵,要求其取值范围在12,18之内。(5分)m=12;n=18;x=m+(n-m)*rand(3) x = 12.0916 17.5909 17.0773 16.4807 14.7960 15.1509 14.6706 14.5119 13.2159 二、 计算题(本题共10个小题,共45分)1. 试生成一个随机矩阵A(34),使用变维函数reshape将A变为一个43的矩阵。(2分)A=rand(3,4);B=reshape(A,4,3) B = 0.6822 0.6979 0.5936 0.3028 0.3784 0.4966 0.5417 0.8600 0.8998 0.1509 0.8537 0.8216 2、要求在闭区间上产生具有10个等距采样点的一维数组。试用两种不同的指令实现。(4分)x=0:0.2*pi:2*piy=linspace(0,2*pi,10) x = Columns 1 through 9 0 0.6283 1.2566 1.8850 2.5133 3.1416 3.7699 4.3982 5.0265 Columns 10 through 11 5.6549 6.2832y = Columns 1 through 9 0 0.6981 1.3963 2.0944 2.7925 3.4907 4.1888 4.8869 5.5851 Column 10 6.2832 3、求解方程组(3分)A=1 1 3 -1;0 1 -1 1;1 1 2 2;1 -1 1 -1;B=-2 1 4 0;R_A=rank(A)X=AB R_A = 4X = 1 -1 0 2 4、求函数零点(6分)(1)求的零点,初值为xx,fx,out=fzero(x.2-5*x+6,0.0) xx = 2.0000fx = 0out = 1 (2)求方程的实数根()solve(x2+4*sin(x)=25) ans = empty sym 5、求函数在区间上的极值。(4分) f=inline(x.3-2*x-5); x1=fminbnd(f,0,2) x3,fx,out=fminbnd(f,0,2) x1 = 0.8165x3 = 0.8165fx = -6.0887out = 1 6、试用Matlab计算函数f(x)=sin(x)/x在区间1,2中的零点与极值。(5分)xx,fx,out=fzero(sin(x)/x,1.0)xx,fx,out=fzero(sin(x)/x,2.0)xx,fx,out=fzero(sin(x)/x,1.5) xx = 3.1416fx = 1.8034e-016out = 1xx = 3.1416fx = 3.8982e-017out = 1xx = 3.1416fx = -1.0238e-016out = 1 7、计算下列数值积分的值(8分)(1) (2)(3) (4)Q1=quad(x+x.3+x.5,-1,1)Q2=quad(sin(x)+cos(x),1,10)Q3=quad(x./(x.4+4),1,10)clear; syms x y; Q4=int(int(sin(y)*(x+y)/(4+x*x),x,1,10),y,1,10) Q1 = 2.2204e-016Q2 = -0.0061Q3 = 0.2718Q4 =-3/2*log(2)*cos(10)-1/2*log(13)*cos(10)+1/2*atan(5)*sin(10)-5*atan(5)*cos(10)+1/2*log(5)*cos(10)-1/2*atan(1/2)*sin(10)+5*atan(1/2)*cos(10)+3/2*log(2)*cos(1)+1/2*log(13)*cos(1)-1/2*atan(5)*sin(1)+1/2*atan(5)*cos(1)-1/2*log(5)*cos(1)+1/2*atan(1/2)*sin(1)-1/2*atan(1/2)*cos(1) 8、设x0.00.30.81.11.62.3,y=0.500.821.141.251.351.40,试求二次多项式拟合系数,并据此计算x1=0.9 1.2时对应的y1。(4分)x=0.0 0.3 0.8 1.1 1.6 2.3; y=0.50 0.82 1.14 1.25 1.35 1.40; p=polyfit(x,y,2) x1=0.9 1.2; y1=polyval(p,x1) p = -0.2387 0.9191 0.5318y1 = 1.1656 1.2909 9、清除已有的图形,在同一坐标系中绘出和对应的曲线,并设置适当的图例和标题。(5分)clf %清除当前图形x=(1:0.01:2)*pi;y1=2*sin(x);y2=3*cos(3*x);x,y1,y2plot(x,y1,r-); %以红实线绘制x-y1hold on; %保持曲线,以便作下一曲线plot(x,y2,b-); %以蓝实线线绘制x-y3hold on; %保持曲线,以便作下一曲线grid on; %增加网格线legend(正弦曲线,余弦曲线,1); %设置不同曲线的图例title(函数曲线的绘制,格式设置示例); %使用结构数组设置图形标题xlabel(横轴);ylabel(纵轴); x = Columns 1 through 10 3.1416 3.1730 3.2044 3.2358 3.2673 3.2987 3.3301 3.3615 3.3929 3.4243 Columns 11 through 20 3.4558 3.4872 3.5186 3.5500 3.5814 3.6128 3.6442 3.6757 3.7071 3.7385 Columns 21 through 30 3.7699 3.8013 3.8327 3.8642 3.8956 3.9270 3.9584 3.9898 4.0212 4.0527 Columns 31 through 40 4.0841 4.1155 4.1469 4.1783 4.2097 4.2412 4.2726 4.3040 4.3354 4.3668 Columns 41 through 50 4.3982 4.4296 4.4611 4.4925 4.5239 4.5553 4.5867 4.6181 4.6496 4.6810 Columns 51 through 60 4.7124 4.7438 4.7752 4.8066 4.8381 4.8695 4.9009 4.9323 4.9637 4.9951 Columns 61 through 70 5.0265 5.0580 5.0894 5.1208 5.1522 5.1836 5.2150 5.2465 5.2779 5.3093 Columns 71 through 80 5.3407 5.3721 5.4035 5.4350 5.4664 5.4978 5.5292 5.5606 5.5920 5.6235 Columns 81 through 90 5.6549 5.6863 5.7177 5.7491 5.7805 5.8119 5.8434 5.8748 5.9062 5.9376 Columns 91 through 100 5.9690 6.0004 6.0319 6.0633 6.0947 6.1261 6.1575 6.1889 6.2204 6.2518 Column 101 6.2832y1 = Columns 1 through 10 0.0000 -0.0628 -0.1256 -0.1882 -0.2507 -0.3129 -0.3748 -0.4363 -0.4974 -0.5580 Columns 11 through 20 -0.6180 -0.6775 -0.7362 -0.7943 -0.8516 -0.9080 -0.9635 -1.0181 -1.0717 -1.1242 Columns 21 through 30 -1.1756 -1.2258 -1.2748 -1.3226 -1.3691 -1.4142 -1.4579 -1.5002 -1.5410 -1.5803 Columns 31 through 40 -1.6180 -1.6542 -1.6887 -1.7215 -1.7526 -1.7820 -1.8097 -1.8355 -1.8596 -1.8818 Columns 41 through 50 -1.9021 -1.9206 -1.9372 -1.9518 -1.9646 -1.9754 -1.9842 -1.9911 -1.9961 -1.9990 Columns 51 through 60 -2.0000 -1.9990 -1.9961 -1.9911 -1.9842 -1.9754 -1.9646 -1.9518 -1.9372 -1.9206 Columns 61 through 70 -1.9021 -1.8818 -1.8596 -1.8355 -1.8097 -1.7820 -1.7526 -1.7215 -1.6887 -1.6542 Columns 71 through 80 -1.6180 -1.5803 -1.5410 -1.5002 -1.4579 -1.4142 -1.3691 -1.3226 -1.2748 -1.2258 Columns 81 through 90 -1.1756 -1.1242 -1.0717 -1.0181 -0.9635 -0.9080 -0.8516 -0.7943 -0.7362 -0.6775 Columns 91 through 100 -0.6180 -0.5580 -0.4974 -0.4363 -0.3748 -0.3129 -0.2507 -0.1882 -0.1256 -0.0628 Column 101 -0.0000y2 = Columns 1 through 10 -3.0000 -2.9867 -2.9469 -2.8809 -2.7893 -2.6730 -2.5330 -2.3705 -2.1869 -1.9839 Columns 11 through 20 -1.7634 -1.5271 -1.2773 -1.0162 -0.7461 -0.4693 -0.1884 0.0942 0.3760 0.6544 Columns 21 through 30 0.9271 1.1914 1.4453 1.6863 1.9123 2.1213 2.3115 2.4812 2.6289 2.7533 Columns 31 through 40 2.8532 2.9278 2.9763 2.9985 2.9941 2.9631 2.9057 2.8226 2.7145 2.5822 Columns 41 through 50 2.4271 2.2503 2.0536 1.8387 1.6075 1.3620 1.1044 0.8370 0.5621 0.2823 Columns 51 through 60 0.0000 -0.2823 -0.5621 -0.8370 -1.1044 -1.3620 -1.6075 -1.8387 -2.0536 -2.2503 Columns 61 through 70 -2.4271 -2.5822 -2.7145 -2.8226 -2.9057 -2.9631 -2.9941 -2.9985 -2.9763 -2.9278 Columns 71 through 80 -2.8532 -2.7533 -2.6289 -2.4812 -2.3115 -2.1213 -1.9123 -1.6863 -1.4453 -1.1914 Columns 81 through 90 -0.9271 -0.6544 -0.3760 -0.0942 0.1884 0.4693 0.7461 1.0162 1.2773 1.5271 Columns 91 through 100 1.7634 1.9839 2.1869 2.3705 2.5330 2.6730 2.7893 2.8809 2.9469 2.9867 Column 101 3.0000 10、试用Matlab分别在、和,条件下使用命令fplot作出函数y=x+cos(x)的图形。(4分)clf subplot(2,2,1),fplot(x+cos(x),0 2*pi); subplot(2,2,2),fplot(x+cos(x),pi 3*pi);subplot(2,2,3),fplot(x+cos(x),-pi pi); subplot(2,2,4),fplot(x+cos(x),pi*-1 1 -1 1); 三、 设计实践题(本题共4个小题,共30分) 1、设计一段程序,用for循环或while循环计算1+2+100之和(5分)s1=0;for i=1:100s1=s1+i;ends1 s1 = 5050 s2=0;j=1;while j=100s2=s2+j;j=j+1;ends2 s2 = 5050 2、编制一个程序,计算的值。(7分)y1=testfun(0.5)y2=testfun(2) y1 = 1.4142y2 = 3 %函数文件function as=testfun(a)if 0a&a1 as=2*sqrt(a);else as=1+a;end3、设有如下数据表:x00.511.522.533.5y12.43.15.07111724对上述数据进行曲线拟合,写出函数表达式。(8分)x=1.0000 0.8992 0.7948 0.7089 0.5941 0.4983 0.4016 0.2987 0.2050 0; y=1.3594 1.3687 1.3777 1.3841 1.3922 1.3984

温馨提示

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

评论

0/150

提交评论