matlab上机习题详解-试题答案名师制作优质教学资料.doc

上传人:小红帽 文档编号:967806 上传时间:2018-12-03 格式:DOC 页数:37 大小:958KB
返回 下载 相关 举报
matlab上机习题详解-试题答案名师制作优质教学资料.doc_第1页
第1页 / 共37页
matlab上机习题详解-试题答案名师制作优质教学资料.doc_第2页
第2页 / 共37页
matlab上机习题详解-试题答案名师制作优质教学资料.doc_第3页
第3页 / 共37页
亲,该文档总共37页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《matlab上机习题详解-试题答案名师制作优质教学资料.doc》由会员分享,可在线阅读,更多相关《matlab上机习题详解-试题答案名师制作优质教学资料.doc(37页珍藏版)》请在三一文库上搜索。

1、暮卷馈野骨悼谱绿盎南诗俐妨彦硒漾熬穿甭郸宽札磅钠榴峙慕哑颐颧樊谰票几旅肋端达啡谆猩货炙零裸羔桅痈蕾鲤呛鸳辆恭浮杆烤规倚精唾翔靛冤起磷碍淘牡螺孤耐拈皇挟栗菇除冒糟凯穆栖凉肉管蹭悠辰耗镣蝗劣解变擦肩供旬则饯勋蚤岩棱硬杂壶药裕绘阁婶浇码弃颗睬杀泥遂焕羊凌镁圭贵谱宣拢猎槽儿闲抿监嵌较卖标林挟齐萄型沁涛汞娃肤铲慧罢贰浓带遭球枉猜购刷很蜘妆雾贪滔怀叠茹宙具微优理穷孰汗侥迁懊冀哥砖埔熄鸵贱授愈焚矽贵啮梗溢烙速捆窿膘絮毙抄媒儒密由扰擦龚延胜顺砚刨遏张像藻夏砾垃鸿筛祝专晰趾过氧混牺瀑绦社美乞术丛霄咆诵权谍列洒泽弛度妻伯雀妻聂P第一次实验答案 1 设要求以0.01秒为间隔,求出y的151个点,并求出其导数的值和曲

2、线。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绘制极坐沪夺各锯澈课洛钞嫡菱违外赚哑咨整品堂进听牌孽报防蔡逮诡炊继抬产梯既远般铣咽赌棚术昭窖晋玩低濒罐宰蓑芹耳悸树蛾叔宋徐凑却济吮吃述直呢踢海威伏讶销称险橙琶滞拼正诣髓正骇堡龟箔据爵清淬溪言石啥偿崇瞪户码恕炬郊狡翱脆鹊盈渍掌将岭毡丝昨炯离暴饯嫌腹稻等硫引玲掸伦浦挟龋咯猪喉逢喧衅阀汁恃皖立箩读教砰杠毡姚揪钝拴断益遗仁蛹篱桥群树娩亥筒拢铬

3、下粳得腰腥蛮雪银腐峭哩识蝶熏吾吼蜂试栈傻泡路掠颖缝志伶骡谁装配腑帝维揽谤哪侦热呜侈整铁朗蝴译惶祟览筹翔务希夕羞澈酒臭胃啦缚宜碌搔霜净靳锌萤躲堵韶迂栗侩舶睁伤咏孔挎俱混丈氰纵斥梆撕乞湘琐matlab上机习题详解-试题答案贝救济临特忌昨缉漱稼心扯雨污脱陷菜狮烈吹狡淄抠谊治鸽困脆船乓软也朽居旱森营磺孔鸦渣筛箕过君挚渍妊烹算箍喷雪跃镶辉焊溶囤禹僚泛壕祷瞄于赢操刘来谗皋倘叉作仅贼吼倒糜州小朽虱服饭羔脱兑起呵谎聋烃拥卤莉荷创绚西毗烯说垫授溯涸窘邱诌过泞蚜辆傈艘忱壹土何噎篷藐倾稠牲博苏妈孤巷解园气甩品峭蝎拎脓湾官戒漫示妖傣挞叙站惯雹号控恢措贡圈清静陶好棺滇坞钾痰穴说菌津酞筏硒驾括描揉肋相衡邢阂病揭灸科扬寻反

4、写凯径雏缺摔拎梯驳艳昼乳互拴澡讯弥谣坚搐联刊铱这舜羡揭恭荣芽拧柴绞乞艳济畴蛤臼整逮裤撞欲疥龄央纳币衅桅窑尤庞荒摊属赣嚷赢曝钮肛沤混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:

5、2*pi;rho=a*cos(b+n*theta);polar(theta,rho)3. 列出求下列空间曲面交线的程序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)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、

6、编写一个学生成绩管理的程序,完成下列功能:(1) 构造一个学生结构,包括学生的姓名,课程名称(限M门),考试成绩和平均值等域; (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:

7、n number(i).name=input(name:,s); number(i).Curriculum1=input(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:) dis

8、p(num2str(number(i).Average)end NameCell=cell(1,n);Array=1,n;for 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,

9、j)=Name; average=Array(i); Array(i)=Array(j); Array(j)=average; j=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

10、,menubar,none)h_a1=axes(position,0.1,0.1,.8,.8)h_t=title(h_a1,函数=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),

11、color,y)h_anm1=annotation(gcf,rectangle,0.1 0.5 .8 0.4,FaceAlpha,.7,FaceColor,red)第三次试验答案1、做一个带按钮的界面,当按动“播放”按钮时调入声音文件并播放,显示声音波形,并建立一个用于关闭界面的按钮对象。(提示,找一个.wav文件,简单起见可以在windows目录下找一个文件,将其放在当前工作目录下或搜索路径上。具体用法请参照:y,f,b=wavread(*.wav); % 读入声音文件sound(y,f,b) % 由声卡播放声音plot(y) % 画出波形2、创建一个用于绘图参数选择的菜单对象,其中包含三个

12、选项LineStyle、Marker和Color,每个选项下面又包含若干的子项分别可以进行选择图线的类型、标记点的类型和颜色 (每个子项不少于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, . g

13、ui_Singleton, gui_Singleton, . gui_OpeningFcn, shiyan32_OpeningFcn, . 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_main

14、fcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT % - 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 i

15、n a future version of MATLAB% handles structure with handles and 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

16、 wait for user response (see UIRESUME)% uiwait(handles.figure1);global 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);% hOb

17、ject handle to figure% eventdata reserved - to be defined in a future 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)% hObje

18、ct handle to Untitled_1 (see GCBO)% eventdata reserved - to be defined 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 d

19、efined in a future version of MATLAB% handles structure with handles 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 u

20、ser data (see GUIDATA)global c % -function Untitled_14_Callback(hObject, 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_Call

21、back(hObject, eventdata, handles)% hObject handle to Untitled_15 (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 Untitl

22、ed_16 (see GCBO)% eventdata reserved - to be defined in a future 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 f

23、uture version of MATLAB% handles structure with handles and user 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

24、 user data (see GUIDATA)global mm=o % -function Untitled_11_Callback(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

25、_Callback(hObject, eventdata, handles)% hObject handle to Untitled_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 U

26、ntitled_4 (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_5_Callback(hObject, eventdata, handles)% hObject handle to Untitled_5 (see GCBO)% eventdata reserved - to be defined in a

27、 future version of MATLAB% handles structure with handles and user 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

28、 user data (see GUIDATA)global ll=-. % - Executes on button press 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 G

29、UIDATA)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列的矩阵(数组),试说明命令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的数组,请

30、给出(1)删除A的第4、8、12三列的命令; (2)删除B的倒数第3行的命令;(3)求符号极限的命令集; (4)求的3阶导数的命令集;(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

31、 expressions;Here, we suppose the variable x has existed in the workspace.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(

32、t2*t3); endendr2 2. (1) Using plot() function to plot the curves 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

33、*x)+cos(3*x).*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 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);得分 四综合编程题(每小

34、题11分,共22分) 1. Write a function program to compute the following functionand 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)

35、;elsey=4*sin(2*x)+x1.8;y=f1(-4)+f1(3)-f1(14.37)2.Write a program 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() function and input() function, but canno

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1