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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

matlab上机习题详解试题答案.docx

1、matlab上机习题详解试题答案matlab上机习题详解_试题答案clcclear P第一次实验答案 x=-2*pi:0.1: 2*pi; 3,y=cos(x).*(0.5+sin(x)*3./(1+x.2); ,4tsin43y,et,, 1( 设 plot(x,y,b*-); 23,title(绘图); xlabel(x坐标); 要求以0.01秒为间隔,求出y的151个点,ylabel(y坐标); 并求出其导数的值和曲线。 legend(原函数) clc gtext(y=cos(x)(0.5+3*sin(x)/(1+x2) clear x=0:0.01:1.5; y=sqrt(3)/2*e

2、xp(-4*x).*sin(4*sqrt(3)*x+pi/35、求下列联立方程的解 ) 3x,4y,7z,12w,4y1=diff(y) subplot(2,1,1) 5x,7y,4z,2w,3 plot(x,y) x,8z,5w,9subplot(2,1,2) plot(x(1:150),y1) ,6x,5y,2z,10w,8clc clear 2绘制极坐标系下曲线(a,b,n自定数据) a=3,4,-7,-12;5,-7,4,2;1,0,8,-5;-6,5,-2,10 ; ,,acosb,n, b=4,-3,9,-8; clc c=b/a; clear x=c(1,1) a=10; y=c

3、(1,2) b=pi/2; z=c(1,3) n=5; w=c(1,4) theta=0:pi/100:2*pi; rho=a*cos(b+n*theta); 6. 假设一曲线数据点为 polar(theta,rho) x = 0:2:4*pi; y = sin(x).*exp(-x/5); 3. 列出求下列空间曲面交线的程序 试将x 的间距调成 0.1,采用不同插值方法进行 22z,2x,3yz,x,2y2插值,并通过子图的形式将不同插值结果和原始数1 据点绘制在同一图形窗口。 clc clear clc x=-5:0.5:5; clear X,Y=meshgrid(x); x=0:2:4*

4、pi; z1=X.2-2*Y.2; y=sin(x).*exp(-x./5); z2=X.*2-Y.*3; x1=0:0.1:4*pi; xlabel(x) y01=interp1(x,y,x1,spline); ylabel(y) y02=interp1(x,y,x1,cubic); zlabel(z) y03=interp1(x,y,x1,nearest); surf(X,Y,z1) y04=interp1(x,y,x1); hold on subplot(3,2,1); surf(X,Y,z2) plot(x,y,o-); k=find(abs(z1-z2)2 a=input(输入密码:

5、) error(输入量太多。); while a=20120520 else disp(密码错误,请重新输入:) S=N*R*R*sin(2*pi/N)/2; clear L=2*N*R*sin(pi/N); a=input(输入密码:) plot(x,y,str) end end if a=20120520 axis equal square disp(密码输入正确!) box on end 3、编写一个学生成绩管理的程序,完成下列2、编写一个函数实现以下功能: 功能: a. 若没有实参输入变量,则用蓝色实线画出(1) 构造一个学生结构,包括学生的姓名,课半径为1的圆; 程名称(限M门),考

6、试成绩和平均值等域; 若有两个实参输入变量N,R,则用蓝色实b.(2) 从键盘上,连续输入N个学生的情况,分线画出外接半径为R的正N多边形; 别将这些学生的情况填入到相应的域,若域中d. 若有两个实参输出变量,则分别输出正多没有值即为空或0,并分别计算其平均值写入边形的面积S和周长L。 到其平均值域。 g. 如果输入变量多于三个或输出变量多于两(3) 根据平均值排序(由高到低),并输出学个则给出错误提示信息。 生的姓名和平均值。 (提示:外接半径为R的正N多边形参数 clc 式:t=0:2*pi/N:2*pi;x=R*sin(t);y=R*cos(t)当Nclear n=input(pleas

7、e input students number:); for x=1:n ?100时,可看作是半径为R的圆) number(x)=struct(name,Curriculum1, ,Curriculum2,Curriculum3,Averagefunction S,L=shiyan22(N,R,str) ,); end for i=1:n switch nargin number(i).name=input(name:,s); case 0 number(i).Curriculum1=input(please N=100;R=1;str=-b; input the scoresnCurricu

8、lum1:); case 1 R=1;str=-b; number(i).Curriculum2=input(Curriculum2:); case 2 set(h_1,linewidth,2) number(i).Curriculum3=input(Curriculum3:)set(get(h_t,parent),color,y) ; h_anm1=annotation(gcf,rectangle,0.1 0.5 .8 number(i).Average=(number(i).Curriculum1+nu0.4,FaceAlpha,.7,FaceColor,red) mber(i).Curr

9、iculum2+number(i).Curriculum3)/3; disp(the average is:) disp(num2str(number(i).Average) 第三次试验答案 end NameCell=cell(1,n); 1、做一个带按钮的界面,当按动“播放”按Array=1,n; for i=1:n 钮时调入声音文件并播放,显示声音波形,并 NameCell(1,i)=number(i).name; Array(i)=number(i).Average; 建立一个用于关闭界面的按钮对象。(提示,end for j=1:(n-1) iptr = j; 找一个.wav文件,简单

10、起见可以在windowsfor i=(j+1):n if Array(i)Array(iptr) %比较相邻前后目录下找一个文件,将其放在当前工作目录下大小? iptr=i; 或搜索路径上。具体用法请参照: end end y,f,b=wavread(*.wav); % 读入声音文 if j=iptr %若后面比前面大,互换 件 Name=NameCell(1,i); NameCell(1,i)=NameCell(1,j); sound(y,f,b) % 由声卡播放 NameCell(1,j)=Name; average=Array(i); 声音 Array(i)=Array(j); Arra

11、y(j)=average; plot(y) % 画出波形 j=1; iptr=j; end end disp(成绩排序如下:) for i=1:n disp(strcat(名次: ,num2str(i), 名字 2、创建一个用于绘图参数选择的菜单对象,,NameCell(1,i), 平均成绩: ,num2str(Array(i) 其中包含三个选项LineStyle、Marker和Color,end 每个选项下面又包含若干的子项分别可以进-0.5x4、使用句柄图像对象绘制曲线:y=2ecos(行选择图线的类型、标记点的类型和颜色 (每x),同时对曲线进行标注和修饰。 个子项不少于3个),当按下“

12、绘图”按钮时,根据选项绘制正弦曲线(缺省时为蓝色无标记x=-12:0.02:12 y=2*exp(-0.5)*x).*cos(pi*x) 实线)。(注意使用全球变量) h_f=figure(Position,200 300 300 300,menubar,none) function varargout = shiyan32(varargin) h_a1=axes(position,0.1,0.1,.8,.8) % SHIYAN32 MATLAB code for shiyan32.fig h_t=title(h_a1,函数 =2*exp(-0.5)*x).*cos(pi*x) % Begin

13、 initialization code - DO NOT EDIT h_1=line(x,y) gui_Singleton = 1; set(gca,xtick,(-6)*pi (-4)*pi (-2)*pi 0 gui_State = struct(gui_Name, (2)*pi (4)*pi (6)*pi) mfilename, . set(gca,xticklabel,(-6)*pi, (-4)*pi, gui_Singleton, (-2)*pi, 0, (2)*pi, (4)*pi,(6)pi) gui_Singleton, . set(gca,xgrid,on,ygrid,on

14、) gui_OpeningFcn, shiyan32_OpeningFcn, . % Get default command line output from handles gui_OutputFcn, structure shiyan32_OutputFcn, . varargout1 = handles.output; gui_LayoutFcn, , . gui_Callback, ); if nargin & ischar(varargin1) % gui_State.gui_Callback = -str2func(varargin1); - end function Untitl

15、ed_1_Callback(hObject, eventdata, handles) if nargout % hObject handle to Untitled_1 (see GCBO) varargout1:nargout = % eventdata reserved - to be defined in a gui_mainfcn(gui_State, varargin:); future version of MATLAB else % handles structure with handles and user gui_mainfcn(gui_State, varargin:);

16、 data (see GUIDATA) end global l % End initialization code - DO NOT EDIT % % - Executes just before shiyan32 is made -visible. - function shiyan32_OpeningFcn(hObject, function Untitled_8_Callback(hObject, eventdata, handles, varargin) eventdata, handles) % This function has no output args, see % hOb

17、ject handle to Untitled_8 (see GCBO) OutputFcn. % eventdata reserved - to be defined in a % hObject handle to figure future version of MATLAB % eventdata reserved - to be defined in a % handles structure with handles and user future version of MATLAB data (see GUIDATA) % handles structure with handl

18、es and user data (see GUIDATA) global m % varargin command line arguments to % shiyan32 (see VARARGIN) - - % Choose default command line output for function color_Callback(hObject, eventdata, shiyan32 handles) handles.output = hObject; % hObject handle to color (see GCBO) % eventdata reserved - to b

19、e defined in a % Update handles structure future version of MATLAB guidata(hObject, handles); % handles structure with handles and user data (see GUIDATA) % UIWAIT makes shiyan32 wait for user response global c (see UIRESUME) % % uiwait(handles.figure1); - global c function Untitled_14_Callback(hObj

20、ect, c=b eventdata, handles) % hObject handle to Untitled_14 (see GCBO) global l % eventdata reserved - to be defined in a l=- future version of MATLAB % handles structure with handles and user global m data (see GUIDATA) m= global c % - Outputs from this function are returned c=r to the command lin

21、e. function varargout = % shiyan32_OutputFcn(hObject, eventdata, -handles) - % varargout cell array for returning output function Untitled_15_Callback(hObject, args (see VARARGOUT); eventdata, handles) % hObject handle to figure % hObject handle to Untitled_15 (see GCBO) % eventdata reserved - to be

22、 defined in a % eventdata reserved - to be defined in a future version of MATLAB future version of MATLAB % handles structure with handles and user % handles structure with handles and user data (see GUIDATA) data (see GUIDATA) % handles structure with handles and user global c data (see GUIDATA) c=

23、b % global m - m=d function Untitled_16_Callback(hObject, % eventdata, handles) -% hObject handle to Untitled_16 (see GCBO) - % eventdata reserved - to be defined in a function Untitled_4_Callback(hObject, future version of MATLAB eventdata, handles) % handles structure with handles and user % hObje

24、ct handle to Untitled_4 (see GCBO) data (see GUIDATA) % eventdata reserved - to be defined in a future version of MATLAB global c % handles structure with handles and user c=g data (see GUIDATA) % global l - l=- function Untitled_17_Callback(hObject, % eventdata, handles) -% hObject handle to Untitl

25、ed_17 (see GCBO) - % eventdata reserved - to be defined in a function Untitled_5_Callback(hObject, future version of MATLAB eventdata, handles) % handles structure with handles and user % hObject handle to Untitled_5 (see GCBO) data (see GUIDATA) % eventdata reserved - to be defined in a future vers

26、ion of MATLAB global c % handles structure with handles and user c=y data (see GUIDATA) % global l - l=- function Untitled_10_Callback(hObject, % eventdata, handles) -% hObject handle to Untitled_10 (see GCBO) - % eventdata reserved - to be defined in a function Untitled_7_Callback(hObject, future v

27、ersion of MATLAB eventdata, handles) % handles structure with handles and user % hObject handle to Untitled_7 (see GCBO) data (see GUIDATA) % eventdata reserved - to be defined in a future version of MATLAB global m % handles structure with handles and user m=o data (see GUIDATA) % global l - l=-. function Untitled_11_Callback

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1