




已阅读5页,还剩5页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
MATLAB的基本操作(一)实验内容及步骤1. 进入MATLAB工作环境,熟悉各窗口的功能。(1) 双击桌面图标,或从“开始”菜单打开MATLAB.exe,启动MATLAB。(2) 查看MATLAB界面各窗口的布局、了解其功能,并完成各窗口之间的切换。(3) 设置当前工作目录。在D盘创建mymatlab目录,并将其作为当前工作目录。今后的实验过程中以此目录作为当前工作目录。2. 计算5.542+cos3517.893.5-e2的值。(1) 在命令窗口(Command Window)中输入程序:a=5.542+cos(3/5*pi)*sqrt(17.89)/3.5-exp(2)(2) 按回车键运行,如果出现“Error”(出错信息),则应找出原因并改正,再运行。(3) 运行结果22.9291过程: a=5.542+cos(3/5*pi)*sqrt(17.89)/3.5-exp(2)a = 22.92913输入矩阵A=428256319, B=111222333, 在命令窗口中执行下列表达式,掌握其含义: A(2,3) A(:,2) A(3,:) A(:,1:2:3) A(:,3).*B(:,2) A(:,3)*B(2,:) A*B A.*B A2 A.2 B/A B./A (1)在命令窗口键入A=4 2 8;2 5 6;3 1 9 ,生成矩阵A;键入B=1 1 1;2 2 2;3 3 3 ,生成矩阵B。(2)记录执行以下表达式的结果:A(2,3)=6,A(6)=1,A(:,2)=251,A(3,:)=319,A(:,1:2:3)=482639,A(:,3).*B(:,2)=81227,A(:,3)*B(2,:)=161616121212181818,A*B=323232303030323232,A.*B=428410129327,A2=442611636351004120111,A.2=16464425369181,B/A=0.50000.0769-0.38461.00000.1538-0.76921.50000.2308-1.1538, B./A=0.25000.50000.12501.00000.40000.33331.00003.00000.3333,B.A=4.00002.00008.00001.00002.50003.00001.00000.33333.0000过程:A=4 2 8;2 5 6;3 1 9A = 4 2 8 2 5 6 3 1 9 B=1 1 1;2 2 2;3 3 3B = 1 1 1 2 2 2 3 3 3 A(2,3)ans = 6 A(6)ans = 1 A(:,2)ans = 2 5 1 A(3,:)ans = 3 1 9 A(:,1:2:3)ans = 4 8 2 6 3 9 A(:,3).*B(:,2)ans = 8 12 27 A(:,3)*B(2,:)ans = 16 16 16 12 12 12 18 18 18 A*Bans = 32 32 32 30 30 30 32 32 32 A.*Bans = 4 2 8 4 10 12 9 3 27 A2ans = 44 26 116 36 35 100 41 20 111 A.2ans = 16 4 64 4 25 36 9 1 81 B/Aans = 0.5000 0.0769 -0.3846 1.0000 0.1538 -0.7692 1.5000 0.2308 -1.1538 B./Aans = 0.2500 0.5000 0.1250 1.0000 0.4000 0.33331.0 3.0000 0.3333 B.Aans = 4.0000 2.0000 8.0000 1.0000 2.5000 3.0000 1.0000 0.3333 3.00004. 产生一个5阶魔方矩阵,将矩阵的第3行4列元素赋值给变量a;将由矩阵第2,3,4行第2,5列构成的子矩阵赋值给变量b。(1)在命令窗口键入clear和clc,观察命令窗口内容的变化。clear命令的作用是清除MATLAB工作空间中保存的变量。clc命令的作用是清除指令窗中显示内容。(2)利用magic()函数产生魔方矩阵,并将此矩阵赋给变量M。程序 M=magic(5)M = 17 24 1 8 15 23 5 7 14 16 4 6 13 20 22 10 12 19 21 311 18 25 2 9(3)将矩阵M的第3行第4列元素赋值给变量a。程序 a=M(3,4)a =20(4) 将由矩阵M第2,3,4行第2,5列构成的子矩阵赋值给变量b。程序 b=M(2 3 4,2 5)b = 5 16 6 22 12 35.建立如下矩阵。(1)20100020100000 20101010程序: 2010*eye(10)ans = 2010 0 0 0 0 0 0 0 0 00 2010 0 0 0 0 0 0 0 0 0 0 2010 0 0 0 0 0 0 0 0 0 0 2010 0 0 0 0 0 0 0 0 0 0 2010 0 0 0 0 0 0 0 0 0 0 2010 0 0 0 0 0 0 0 0 0 0 2010 0 0 0 0 0 0 0 0 0 0 2010 0 0 0 0 0 0 0 0 0 0 2010 0 0 0 0 0 0 0 0 0 0 2010 (2)06606666 088程序: 6*ones(8)-6*eye(8)ans = 0 6 6 6 6 6 6 6 6 0 6 6 6 6 6 6 6 6 0 6 6 6 6 6 6 6 6 0 6 6 6 6 6 6 6 6 0 6 6 6 6 6 6 6 6 0 6 6 6 6 6 6 6 6 0 6 6 6 6 6 6 6 6 06.设有分块矩阵A=E33R32O23D22,其中E,R,O,D分别为单位矩阵、随机阵、零阵和对角阵e002。(1)生成单位阵E,程序: E=eye(3)E = 1 0 0 0 1 0 0 0 1(2)生成随机阵R,程序: R=rand(3,2)R = 0.9501 0.4860 0.2311 0.8913 0.6068 0.7621(3)生成零阵O,程序: O=zeros(2,3)O = 0 0 0 0 0 0(4)生成对角阵D,程序: D=exp(1) 0;0 2D = 2.7183 0 0 2.0000(5)生成矩阵A,程序: A=E R;O DA = 1.0000 0 0 0.9501 0.4860 0 1.0000 0 0.2311 0.8913 0 0 1.0000 0.6068 0.7621 0 0 0 2.7183 0 0 0 0 0 2.00007.查看polt函数的帮助文档,并查看Demos中关于plot的示例程序。(1)在命令窗口输入help plot,查看plot函数的帮助文档。(2)点击“help”菜单,选择“Demons”子菜单,在“MATLAB”中选择“Graphics”,再选择“2-D Plots”,即可看到关于plot函数的示例程序。过程:(1) help plot PLOT Linear plot. PLOT(X,Y) plots vector Y versus vector X. If X or Y is a matrix, then the vector is plotted versus the rows or columns of the matrix, whichever line up. If X is a scalar and Y is a vector, length(Y) disconnected points are plotted. PLOT(Y) plots the columns of Y versus their index. If Y is complex, PLOT(Y) is equivalent to PLOT(real(Y),imag(Y). In all other uses of PLOT, the imaginary part is ignored. Various line types, plot symbols and colors may be obtained with PLOT(X,Y,S) where S is a character string made from one element from any or all the following 3 columns: b blue . point - solid g green o circle : dotted r red x x-mark -. dashdot c cyan + plus - dashed m magenta * star (none) no line y yellow s square k black d diamond v triangle (down) triangle (up) triangle (right) p pentagram h hexagram For example, PLOT(X,Y,c+:) plots a cyan dotted line with a plus at each data point; PLOT(X,Y,bd) plots blue diamond at each data point but does not draw any line. PLOT(X1,Y1,S1,X2,Y2,S2,X3,Y3,S3,.) combines the plots defined by the (X,Y,S) triples, where the Xs and Ys are vectors or matrices and the Ss are strings. For example, PLOT(X,Y,y-,X,Y,go) plots the data twice, with a solid yellow line interpolating green circles at the data points. The PLOT command, if no color is specified, makes automatic use of the colors specified by the axes ColorOrder property. The default ColorOrder is listed in the table above for color systems where the default is blue for one line, and for multiple lines, to cycle through the first six colors in the table. For monochrome systems, PLOT cycles over the axes LineStyleOrder property. If you do not specify a marker type, PLOT uses no marker. If you do not specify a line style, PLOT uses a solid line. PLOT(AX,.) plots into the axes with handle AX. PLOT returns a column vector of handles to lineseries objects, one handle per plotted line. The X,Y pairs, or X,Y,S triples, can be followed by parameter/value pairs to specify additional properties of the lines. For example, PLOT(X,Y,LineWidth,2,Color,.6 0 0) will create a plot with a dark red line width of 2 points. Backwards compatibility PLOT(v6,.) creates line objects instead of lineseries objects for compatibility with MATLAB 6.5 and earlier. See also plottools, semilogx, semilogy, loglog, plotyy, plot3, grid, title, xlabel, ylabel, axis, axes, hold, legend, subplot, scatter. Overloaded functions or methods (ones with the same name in other directories) help phytree/plot.m help cfit/plot.m help fints/plot.m help idmodel/plot.m help idfrd/plot.m help iddata/plot.m help mpc/plot.m help frd/plot.m help dspdata/plot.
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 房产经纪服务合同(标准版)
- 城乡供水管网水力分析
- 污水处理厂远程监控方案
- 电力接入与配电设计方案
- 2025年淮北濉溪县龙华学校教师招聘考试参考试题及答案解析
- 2025年湖南益阳桃江县选调县外教师20人备考练习试题及答案解析
- 风电机组风速与风向监测方案
- 2025年8月广东广州奥林匹克中学编外聘用制专任教师招聘1人备考练习题库及答案解析
- 2025年广西来宾市武宣县人民医院公开招聘6人(第三期)备考练习题库及答案解析
- 2025内蒙古包头医学院招聘管理助理和教学助理岗工作人员22人考试参考试题及答案解析
- 物流车队轮胎管理制度
- 碳化硅项目可行性分析报告
- 2025年试验检测师之桥梁隧道工程能力检测试卷A卷附答案
- 老年共病管理中国专家共识(2023)课件
- 惠州市惠阳区水资源综合规划 修编(2020-2035 年)
- 应聘简历模板进厂
- 公司配送员工管理制度
- 工厂员工星级管理制度
- 我国汽车产业在全球价值链中的地位剖析与影响因素探究
- 衢州龙游县龙新高速公路投资有限公司招聘笔试题库2025
- 《应用语文(第3版)》技工院校语文课程全套教学课件
评论
0/150
提交评论