欢迎来到沃文网! | 帮助中心 分享知识,传播智慧!
沃文网
全部分类
  • 教学课件>
  • 医学资料>
  • 技术资料>
  • 学术论文>
  • 资格考试>
  • 建筑施工>
  • 实用文档>
  • 其他资料>
  • ImageVerifierCode 换一换
    首页 沃文网 > 资源分类 > DOC文档下载
    分享到微信 分享到微博 分享到QQ空间

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

    • 资源ID:968638       资源大小:879.04KB        全文页数:37页
    • 资源格式: DOC        下载积分:20积分
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: QQ登录 微博登录
    二维码
    微信扫一扫登录
    下载资源需要20积分
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,下载更划算!
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    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. 列出求下列空间曲面交线的程序clccle

    2、arx=-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)2 error(输入量太多。);else S=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:n number(x)=struct(name,Curriculum1,Curriculum2,Curriculum3,Average,);endfor i=1:n number(i).name=input(name:,s); number(i).Curriculum1=input(plea

    4、se 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;for

    5、i=1:n NameCell(1,i)=number(i).name; Array(i)=number(i).Average;endfor j=1:(n-1) iptr = j; for i=(j+1):n if Array(i)Array(iptr) %比较相邻前后大小 iptr=i; end end if 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

    6、=1; iptr=j; endenddisp(成绩排序如下:)for i=1:n disp(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,函数=

    7、2*exp(-0.5)*x).*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,

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

    9、个子项不少于3个),当按下“绘图”按钮时,根据选项绘制正弦曲线(缺省时为蓝色无标记实线)。(注意使用全球变量)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_OpeningFc

    10、n, . gui_OutputFcn, shiyan32_OutputFcn, . gui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);end if nargout varargout1:nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT E

    11、DIT % - Executes just before shiyan32 is made visible.function shiyan32_OpeningFcn(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

    12、user data (see GUIDATA)% varargin command line arguments to shiyan32 (see VARARGIN) % 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);g

    13、lobal cc=bglobal ll=-global mm= % - Outputs from this function are returned to the 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 fu

    14、ture version of MATLAB% handles structure with handles and user data (see GUIDATA) % 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 de

    15、fined in a future version of MATLAB% handles structure with handles and user data (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 hand

    16、les and user data (see GUIDATA)global m % -function color_Callback(hObject, eventdata, 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(h

    17、Object, eventdata, handles)% hObject handle to Untitled_14 (see GCBO)% eventdata reserved - 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

    18、(see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles 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

    19、version of MATLAB% handles structure with handles and user data (see GUIDATA)global 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

    20、data (see GUIDATA) global cc=y% -function Untitled_10_Callback(hObject, eventdata, 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_Callb

    21、ack(hObject, eventdata, handles)% hObject handle to Untitled_11 (see GCBO)% eventdata 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 Untitle

    22、d_13 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% 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 fut

    23、ure version of MATLAB% handles structure with handles and user data (see GUIDATA)global 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 use

    24、r data (see GUIDATA)global ll=- % -function Untitled_7_Callback(hObject, eventdata, 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

    25、 in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject 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

    26、=strcat(l,m,c);plot(x,y,s)2. 设和是两个10行10列的矩阵(数组),试说明命令A*B, A/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的数组,请给出(1)删除A的第4、8、12三列的命令; (2)删除B的倒数第3行的命令;(3)求符号极限的命令集; (4)求的3阶导数的命令

    27、集;(5)计算定积分的命令,并给出计算结果(!)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;Here, we suppose the variable x has existed in the w

    28、orkspace.for i=1:10 for j=1:10xbar(i)=xbar(i)+x(i,j); end xbar(i)=xbar(i)/10;endfor i=1:10 for j=1:10 t1=0;t2=0;t3=0; for k=1:3 t1=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; end r2(i,j)=t1/sqrt(t2*t3); endendr2 2. (1) Using plot() function to plot the curves

    29、of and in 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).*exp(-2*x);z=sin(x)/x;plot(x,y,r,x,z,g)(2)fplot(sin(

    30、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 functionin the range of and , respectively.x=-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);得分 四综合编程题(每小题11分,共22分) 1. Write a function program to compute the following f

    31、unctionand call this function program to compute the value of in main program or command window, there, shows the factorial (阶乘) of . 提示:对x取整的函数有fix(x), floor(x), round(x) 和ceil(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

    32、to compute the sample mean,and the sample skewness (偏度) .for the following three case:(1) n and exist in Workspace of Matlab. It is no any limit;(2) n and are unknown variables. Please input x by keyboard one by one, and give a mark of end the data input. Examinees can use loop statement and length(

    33、) function and input() function, but cannot use mean() function, std() function, and var() function directly (可以使用循环语句和length()函数、input()函数等进行编程,但不能直接使用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

    34、(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常用操作界面包括 命令窗口 、工作空间窗口、 命令历史窗口 、当前目录窗口 、内存数组编辑器、M文件编辑/调试器、帮助导航/浏览器、图形窗口等。2、MATLAB中Inf或inf表示 无穷大 、NaN或nan表示 不是一个数 、nargout表示 函数输出变量数目 。3、工作空间浏览器主要用于内存变量的 查阅 、 保持 和 编辑 。4、MATLAB实现将全下标转换为单下标的指令为 sub2ind 、据单下标换算出全下标的指令为 ind2sub 。5、MATLAB中clf用于 清除图形窗口 、clc用于 清除指令窗口中显示内容 、clear用于 清除MATLAB工作空间中保存的变量 。二、简答题(每题5分,共20分) 1、简述MATLAB历史指令窗的主要作用。答:历史指令窗记录着用户在MATLAB指令窗中所输入过的所有指令。历史记录包括:每次开启MATLAB的时间,每次开启MATLAB后在指令窗中运行过的所有指令。应用功能有单行或多行指令的复制和运行、生成M文件等。2、简述MATLAB函数的基本结构。答:典型M函数文件的结构:


    注意事项

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




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服点击这里,给沃文网发消息,QQ:2622162128 - 联系我们

    版权声明:以上文章中所选用的图片及文字来源于网络以及用户投稿,由于未联系到知识产权人或未发现有关知识产权的登记,如有知识产权人并不愿意我们使用,如有侵权请立即联系:2622162128@qq.com ,我们立即下架或删除。

    Copyright© 2022-2024 www.wodocx.com ,All Rights Reserved |陕ICP备19002583号-1

    陕公网安备 61072602000132号     违法和不良信息举报:0916-4228922