ImageVerifierCode 换一换
格式:DOC , 页数:37 ,大小:1.05MB ,
资源ID:2126011      下载积分:15 文钱
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,省得不是一点点
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.wenke99.com/d-2126011.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: QQ登录   微博登录 

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(matlab上机习题详解-试题答案.doc)为本站会员(hw****26)主动上传,文客久久仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知文客久久(发送邮件至hr@wenke99.com或直接QQ联系客服),我们立即给予删除!

matlab上机习题详解-试题答案.doc

1、P 第一次实验答案1 设要求以 0.01 秒为间隔,求出 y 的 151 个点,并求出其导数的值和曲线。clcclearx=0:0.01:1.5;y=sqrt(3)/2*exp(-4*x).*sin(4*sqrt(3)*x+pi/3)y1=diff(y)subplot(2,1,1)plot(x,y)subplot(2,1,2)plot(x(1:150),y1)2 绘制极坐标系下曲线(a,b,n 自定数据)clccleara=10;b=pi/2;n=5;theta=0:pi/100:2*pi;rho=a*cos(b+n*theta);polar(theta,rho)3. 列出求下列空间曲面交线的

2、程序clcclearx=-5:0.5:5;X,Y=meshgrid(x);z1=X.2-2*Y.2;z2=X.*2-Y.*3;xlabel(x)ylabel(y)zlabel(z)surf(X,Y,z1)hold onsurf(X,Y,z2)k=find(abs(z1-z2)2error(输入量太多。);elseS=N*R*R*sin(2*pi/N)/2; L=2*N*R*sin(pi/N); plot(x,y,str)endaxis equal squarebox on3、编写一个学生成绩管理的程序,完成下列功能:(1) 构造一个学生结构,包括学生的姓名,课程名称(限 M 门) ,考试成绩和

3、平均值等域; (2) 从键盘上,连续输入 N 个学生的情况,分别将这些学生的情况填入到相应的域,若域中没有值即为空或 0,并分别计算其平均值写入到其平均值域。(3) 根据平均值排序(由高到低) ,并输出学生的姓名和平均值。clcclearn=input(please input students number:);for x=1:nnumber(x)=struct(name,Curriculum1,Curriculum2,Curriculum3,Average,);endfor i=1:nnumber(i).name=input(name:,s);number(i).Curriculum1=i

4、nput(please input the scoresnCurriculum1:);number(i).Curriculum2=input(Curriculum2:);number(i).Curriculum3=input(Curriculum3:);number(i).Average=(number(i).Curriculum1+number(i).Curriculum2+number(i).Curriculum3)/3;disp(the average is:)disp(num2str(number(i).Average)end NameCell=cell(1,n);Array=1,n;

5、for i=1:nNameCell(1,i)=number(i).name;Array(i)=number(i).Average;endfor j=1:(n-1)iptr = j;for i=(j+1):nif Array(i)Array(iptr) %比较相邻前后大小iptr=i;endendif j=iptr %若后面比前面大,互换Name=NameCell(1,i); NameCell(1,i)=NameCell(1,j);NameCell(1,j)=Name;average=Array(i);Array(i)=Array(j);Array(j)=average;j=1;iptr=j;e

6、ndenddisp(成绩排序如下:)for i=1:ndisp(strcat(名次: ,num2str(i), 名字 ,NameCell(1,i), 平均成绩: ,num2str(Array(i)end 4、使用句柄图像对象绘制曲线:y=2e -0.5xcos(x),同时对曲线进行标注和修饰。x=-12:0.02:12y=2*exp(-0.5)*x).*cos(pi*x)h_f=figure(Position,200 300 300 300,menubar,none)h_a1=axes(position,0.1,0.1,.8,.8)h_t=title(h_a1,函数=2*exp(-0.5)*x

7、).*cos(pi*x)h_1=line(x,y)set(gca,xtick,(-6)*pi (-4)*pi (-2)*pi 0 (2)*pi (4)*pi (6)*pi)set(gca,xticklabel,(-6)*pi, (-4)*pi, (-2)*pi, 0, (2)*pi, (4)*pi,(6)pi)set(gca,xgrid,on,ygrid,on)set(h_1,linewidth,2)set(get(h_t,parent),color,y)h_anm1=annotation(gcf,rectangle,0.1 0.5 .8 0.4,FaceAlpha,.7,FaceColor,

8、red)第三次试验答案1、做一个带按钮的界面,当按动“播放”按钮时调入声音文件并播放,显示声音波形,并建立一个用于关闭界面的按钮对象。 (提示,找一个.wav 文件,简单起见可以在 windows目录下找一个文件,将其放在当前工作目录下或搜索路径上。具体用法请参照:y,f,b=wavread(*.wav); % 读入声音文件sound(y,f,b) % 由声卡播放声音plot(y) % 画出波形2、创建一个用于绘图参数选择的菜单对象,其中包含三个选项 LineStyle、Marker 和Color,每个选项下面又包含若干的子项分别可以进行选择图线的类型、标记点的类型和颜色 (每个子项不少于 3

9、 个),当按下“绘图”按钮时,根据选项绘制正弦曲线(缺省时为蓝色无标记实线) 。 (注意使用全球变量)function varargout = shiyan32(varargin)% SHIYAN32 MATLAB code for shiyan32.fig% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct(gui_Name, mfilename, .gui_Singleton, gui_Singleton, .gui_OpeningFcn, shiyan32_OpeningFcn, .gu

10、i_OutputFcn, shiyan32_OutputFcn, .gui_LayoutFcn, , .gui_Callback, );if nargin endif nargoutvarargout1:nargout = gui_mainfcn(gui_State, varargin:);elsegui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT % - Executes just before shiyan32 is made visible.function shiyan32_Openi

11、ngFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to shiyan32 (see VAR

12、ARGIN)% Choose default command line output for shiyan32handles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes shiyan32 wait for user response (see UIRESUME)% uiwait(handles.figure1);global cc=bglobal ll=-global mm= % - Outputs from this function are returned to t

13、he command line.function varargout = shiyan32_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDAT

14、A)% Get default command line output from handles structurevarargout1 = handles.output;% -function Untitled_1_Callback(hObject, eventdata, handles)% hObject handle to Untitled_1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data

15、(see GUIDATA)global l % -function Untitled_8_Callback(hObject, eventdata, handles)% hObject handle to Untitled_8 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global m % -function color_Callback(hObject, eventd

16、ata, handles)% hObject handle to color (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global c % -function Untitled_14_Callback(hObject, eventdata, handles)% hObject handle to Untitled_14 (see GCBO)% eventdata r

17、eserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global cc=r % -function Untitled_15_Callback(hObject, eventdata, handles)% hObject handle to Untitled_15 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% hand

18、les structure with handles and user data (see GUIDATA)global cc=b % -function Untitled_16_Callback(hObject, eventdata, handles)% hObject handle to Untitled_16 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)globa

19、l cc=g % -function Untitled_17_Callback(hObject, eventdata, handles)% hObject handle to Untitled_17 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global cc=y% -function Untitled_10_Callback(hObject, eventdata,

20、handles)% hObject handle to Untitled_10 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global mm=o % -function Untitled_11_Callback(hObject, eventdata, handles)% hObject handle to Untitled_11 (see GCBO)% eventda

21、ta reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global mm=* % -function Untitled_13_Callback(hObject, eventdata, handles)% hObject handle to Untitled_13 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB%

22、handles structure with handles and user data (see GUIDATA)global mm=d % -function Untitled_4_Callback(hObject, eventdata, handles)% hObject handle to Untitled_4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)glo

23、bal ll=- % -function Untitled_5_Callback(hObject, eventdata, handles)% hObject handle to Untitled_5 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global ll=- % -function Untitled_7_Callback(hObject, eventdata,

24、handles)% hObject handle to Untitled_7 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global ll=-. % - Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject

25、handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global s global l global m global cx=0:0.1:2*pi;y=sin(x);s=strcat(l,m,c);plot(x,y,s)2. 设 和 是两个 10 行 10 列10)(jiaA10)(jibB的矩阵(数组) ,试说明命令 A*B, A/

26、B, AB, A.*(B.A), A./B, A.B 和 sin(A).*exp(B)的涵义。A,B 的矩阵乘法,矩阵 A 乘以 B 的逆,矩阵 B 乘以 A 的逆,B 的每个元素的对应 A 次幂乘以 A 对应的每个元素A 的每个元素除以 B 对应的每个元素,B 的每个元素除以 A 对应的每个元素,A 的每个元素的正弦与 B 对应的每个元素的指数求积,3. 设 A 为 数组,B 为一个行数大于 3 的数组,请147给出(1)删除 A 的第 4、8、12 三列的命令; (2)删除 B的倒数第 3 行的命令;(3)求符号极限 的命令集; (4)求0tan()limx的 3 阶导数的命令集;2arc

27、tn1xye(5)计算定积分 的命令,并给出计(sin)d算结果(!)A(:,4 8 12)=(2)B(end-2)=(3)syms m n xlimit(tan(m*x)/(n*x)(4)syms x yy=atan(x+3)/(x-2)-log(1+exp(-2)*x)diff(y,3)(5)syms xint(abs(x)+sin(x)*x2,-1,1)三基本编程题(每小题 10 分,共 30 分)1. Write a program to compute the following expressions;10210102(),1,0(ikijkjijikijkjxxr ijHere,

28、 we suppose the variable x has existed in the workspace.for i=1:10for j=1:10xbar(i)=xbar(i)+x(i,j);endxbar(i)=xbar(i)/10;endfor i=1:10for j=1:10t1=0;t2=0;t3=0;for k=1:3t1=t1+(x(i,k)-xbar(i)*(x(j,k)-xbar(j);t2=t2+(x(i,k)-xbar(i)2;t3=t3+(x(j,k)-xbar(j)2;endr2(i,j)=t1/sqrt(t2*t3);endendr22. (1) Using p

29、lot() function to plot the curves of and 2sin(2)cos3exyxsinxzin the range of , let their color are red and ,green respectively, and add the grid to the figure.(2) Using fplot() function and ezplot() function to plot above-mentioned (上述的) curves respectively.(1)x=-2*pi:pi/100:2*pi;y=(sin(2*x)+cos(3*x

30、).*exp(-2*x);z=sin(x)/x;plot(x,y,r,x,z,g)(2)fplot(sin(2*x)+cos(3*x).*exp(-2*x), sin(x)/x,-2*pi 2*pi)3. Plot the 3D mesh figure and 3D surface figure of the function 22/(1)(,)9(1)exyfxyin the range of and , respectively.44x=-4:1/100:4;y=-4:1/100:4;z=9(1-x)2*exp(-x2/2-(y+1)2)mesh(x,y,z);surf(x,y,z);四综

31、合编程题(每小题 11 分,共 22 分)1. Write a function program to compute the following function 1.8|2!, ()f1(x)34sin(),xix整 数其 他and call this function program to compute the value of in main program or y=-+f-.37command window, there, shows the factorial (阶乘) of |!i.|i提示:对 x 取整的函数有 fix(x), floor(x), round(x) 和 ce

32、il(x) .fuction y=f1(x) %f1.mif x-fix(x)= =0y=prod(1:abs(2*x);elsey=4*sin(2*x)+x1.8;y=f1(-4)+f1(3)-f1(14.37)2.Write a program to compute the sample mean得分得分,1xbar=nixand the sample skewness (偏度) .31ske)niifor the following three case:(1) n and exist in Workspace of ,2nxxMatlab. It is no any limit;(2)

33、 n and are unknown variables. 1Please input x by keyboard one by one, and give a mark of end the data input. Examinees can use loop statement and length() function and input() function, but cannot use mean() function, std() function, and var() function directly (可以使用循环语句和 length()函数、input() 函数等进行编程,

34、但不能直接使用 mean()、std()和 var()等函数). (1)s=0;for i=1:ns=s+x(i);endxbar=s/nm=0;for i=1:nm=m+(x(i)-xbar)3;endske=m/n(2)x(1)=input(请输入 x );i=1;s=0;while(x(i)=a)s=s+x(i);i=i+1;x(i)=input(请输入 x ,输a结束);endxbar=s/(i-1)m=0;for j=1:i-1m=m+(x(i)-xbar)3;endske=m/(i-1)一、填空题1、MATLAB 常用操作界面包括 命令窗口 、工作空间窗口、 命令历史窗口 、当前目

35、录窗口 、内存数组编辑器、M 文件编辑/调试器、帮助导航/ 浏览器、图形窗口等。2、MATLAB 中 Inf 或 inf 表示 无穷大 、NaN或 nan 表示 不是一个数 、nargout 表示 函数输出变量数目 。3、工作空间浏览器主要用于内存变量的 查阅 、 保持 和 编辑 。4、MATLAB 实现将全下标转换为单下标的指令为 sub2ind 、据单下标换算出全下标的指令为 ind2sub 。5、MATLAB 中 clf 用于 清除图形窗口 、clc 用于 清除指令窗口中显示内容 、clear 用于 清除 MATLAB 工作空间中保存的变量 。二、简答题(每题 5分,共 20分)1、简述

36、 MATLAB 历史指令窗的主要作用。答:历史指令窗记录着用户在 MATLAB 指令窗中所输入过的所有指令。历史记录包括:每次开启 MATLAB 的时间,每次开启 MATLAB 后在指令窗中运行过的所有指令。应用功能有单行或多行指令的复制和运行、生成 M 文件等。2、简述 MATLAB 函数的基本结构。答:典型 M 函数文件的结构:函数申明行、H1 行、在线帮助文本区、编写和修改记录、函数体。3、简述绘制二维图形的一般步骤。绘制二维图形的一般步骤为:曲线数据准备、选定图形窗及子图位置、调用二维曲线绘图指令、设置轴的范围、坐标分格线、图形注释、图形的精细操作。三、阅读程序并回答问题(每题 4分,

37、共 28分)1、写出下列指令运行结果。A=zeros(2,4); A(:)=1:8; s=2 3 5;A(s)Sa=10 20 30A(s)=Saans =2 3 5Sa =102030A =1 20 30 710 4 6 8 2、写出下列指令运行结果。A=reshape(1:16,2,8) reshape(A,4,4) s=1 3 6 8 9 11 14 16;A(s)=0A =1 3 5 7 9 11 13 15 2 4 6 8 10 12 14 16ans =1 5 9 132 6 10 143 7 11 154 8 12 16A =0 0 5 7 0 0 13 152 4 0 0 10

38、 12 0 03、写出下列指令运行结果。A=1,2;3,4; B=-1,-2;2,1;S=3;A.*Bans =-1 -46 4A*Bans =3 05 -2S.*Aans =3 69 12S*Bans =-3 -66 34、下面的函数主要完成什么功能?function f=factor(n)if n=aendif nargout1,error(wrong);endss=1;for t=1:n,ss=ss+(xt)./(2*t-1);s=ss;end zh(35/60,35)ans =1.76772. 已知系统的框图如下图所示,请推导出从输入信号r(t)到输出信号 y(t)的总系统模型。2.s

39、yms G1 G2 G3 G4 G5 G6 G7 H1 H2 H3 H4c1=feedback(G4,H4);c2=feedback(G3*G2,H2);c3=feedback(G5*c1,H3);G=feedback(G6+G7)*c3*c2*G1,H1)3. 已知单位负反馈控制系统的被控对象及控制器的传递函数分别为 , )20/1(5./6)(ssG )23(5.10)(ssGc试判断系统的稳定性,并用时域响应检验得出的结论。 s=tf(s)Transfer function:s Gs=16*(1+s/2.5)/s*(1+s/0.5)*(1+s/20)Transfer function:6

40、.4 s + 16-0.1 s3 + 2.05 s2 + s Gc=20*(s+1)*(s+2)/(s+1.5)*(s+23)Transfer function:20 s2 + 60 s + 40-s2 + 24.5 s + 34.5 GG=feedback(Gs*Gc,1)Transfer function:128 s3 + 704 s2 + 1216 s + 640-0.1 s5 + 4.5 s4 + 182.7 s3 + 799.2 s2 + 1251 s + 640 eig(GG)ans =-20.1421 +34.9785i-20.1421 -34.9785i-1.8264 + 0.

41、5997i-1.8264 - 0.5997i-1.0630 根都有负实部 则系统稳定 step(GG,1)4. 考虑简单的线性微分方程,)2sin(2413453)()( teyytt且方程的初值为 y(0)=1,y(0)=y”(0)=1/2,y (3)(0)=0.6,,请用 Simulink 搭建起系统的仿真模型,并绘制出仿真结果曲线。2.6 求 的共轭 i4i93i4i67i23571584x转置。 x=4+8i 3+5i 2-7i 1+4i 7-5i;3+2i 7-6i 9+4i 3-9i 4+4i; xans =4.0000 - 8.0000i 3.0000 - 2.0000i3.00

42、00 - 5.0000i 7.0000 + 6.0000i2.0000 + 7.0000i 9.0000 - 4.0000i1.0000 - 4.0000i 3.0000 + 9.0000i7.0000 + 5.0000i 4.0000 - 4.0000i2.7 计算 与 的数组乘积。572396a86412b a=6 9 3;2 7 5; b=2 4 1;4 6 8; a.*bans =12 36 38 42 402.9 对于 ,如果 , ,BAX7534629A863B求解 X。 A=4 9 2;7 6 4;3 5 7; B=37 26 28; X=ABX =-0.51184.04271.

43、33182.10 已知: ,分别计算 a 的数组平方987654321a和矩阵平方,并观察其结果。 a=1 2 3;4 5 6;7 8 9; a.2ans =1 4 916 25 3649 64 81 a2ans =30 36 4266 81 96102 126 1502.11 , ,观察 a 与 b463521a263478b之间的六种关系运算的结果。 a=1 2 3;4 5 6; b=8 7 4;3 6 2; abans =0 1 01 0 1 a=bans =0 1 01 0 1 a a a=bans =0 0 00 0 0 a=bans =1 1 11 1 12.13 在 sin(x)运算中,x 是角度还是弧度?在 sin

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。