1、1闽 江 学 院 电 子 系实 验 报 告学生姓名:陈燕燕 班级:10 电本 学 号:120101004117课程:MATLAB一、 实验题目:MATLAB 操作基础二、 实验地点:实验楼 A210三、 实验目的:1、熟悉 MATLAB 的操作环境及基本操作方法。2、掌握 MATLAB 的搜索路径及其设置方法。3、熟悉 MATLAB 帮助信息的查阅方法。四、实验内容:1、先建立自己的工作目录,再将自己的工作目录设置到MATLAB 搜索路径下,再试验用 help 命令能否查询到自己的工作目录。2、在 MATLAB 环境下验证例 1-1 至 1-4,并完成以下题目:(1)绘制右图所示图形(2)求
2、383、利用 MATLAB 的帮助功能分别查询inv,plot、max、round 等函数的功能及用法。4、在工作空间建立一个变量 a ,同时在当前目录下建立一个 M 文件:a.m,试在命令窗口输入a,观察结果,并解释原因。四、 实验结果1. helpHELP topics:E:MATLAB 实验 - (No table of contents file)matlabgeneral - General purpose commands.matlabops - Operators and special characters.matlablang - Programming language c
3、onstructs.matlabelmat - Elementary matrices and matrix manipulation.matlabelfun - Elementary math functions.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1-0.8-0.6-0.4-0.200.20.40.60.812matlabspecfun - Specialized math functions.matlabmatfun - Matrix functions - numerical linear algebra.matlabdatafun - Da
4、ta analysis and Fourier transforms.matlabaudio - Audio support.matlabpolyfun - Interpolation and polynomials.matlabfunfun - Function functions and ODE solvers.matlabsparfun - Sparse matrices.matlabgraph2d - Two dimensional graphs.matlabgraph3d - Three dimensional graphs.matlabspecgraph - Specialized
5、 graphs.matlabgraphics - Handle Graphics.matlabuitools - Graphical user interface tools.matlabstrfun - Character strings.matlabiofun - File input/output.matlabtimefun - Time and dates.matlabdatatypes - Data types and structures.matlabverctrl - Version control.matlabwinfun - Windows Operating System
6、Interface Files (DDE/COM)winfuncomcli - (No table of contents file)matlabdemos - Examples and demonstrations.toolboxlocal - Preferences.aeroblksaeroblks - Aerospace Blocksetaeroblksaerodemos - Aerospace Blockset demonstrations and examples.ccslinkccslink - MATLAB Link for Code Composer Studio(tm) cc
7、slinkccsdemos - MATLAB Link for Code Composer Studio (tm) Demosccslinkrtdxblks - RTDX (tm) Blocks combuildercombuilder - MATLAB COM Builder.toolboxcompiler - MATLAB Compilercurvefitcurvefit - Curve Fitting Toolboxcurvefitcftoolgui - (No table of contents file)daqdaq - Data Acquisition Toolbox.daqdaq
8、guis - Data Acquisition Toolbox - Data Acquisition Soft Instruments.daqdaqdemos - Data Acquisition Toolbox - Data Acquisition Demos.databasedatabase - Database Toolbox.databasedbdemos - Database Toolbox Demonstration Functions.databasevqb - Visual Query Builder functions.datafeeddatafeed - Datafeed
9、Toolbox.datafeeddfgui - Datafeed Toolbox Graphical User Interfacetoolboxexlink - Excel Link.toolboxfixpoint - Fixed-Point Blocksetfuzzyfuzzy - Fuzzy Logic Toolbox.fuzzyfuzdemos - Fuzzy Logic Toolbox Demos.identident - System Identification Toolbox.identidobsolete - (No table of contents file)3identi
10、dguis - (No table of contents file)identidutils - (No table of contents file)identiddemos - (No table of contents file)identidhelp - (No table of contents file)imagesimages - Image Processing Toolbox.imagesimdemos - Image Processing Toolbox - demos and sample imagesinstrumentinstrument - Instrument
11、Control Toolbox.instrumentinstrumentdemos - (No table of contents file)matlabxlmatlabxl - MATLAB Excel Builder.mutoolscommands - Mu-Analysis and Synthesis Toolbox.mutoolssubs - Mu-Analysis and Synthesis Toolbox.toolboxncd - Nonlinear Control Design Blocksetnnetnnet - Neural Network Toolbox.nnetnnuti
12、ls - (No table of contents file)nnetnncontrol - Neural Network Toolbox Control System Functions.nnetnndemos - Neural Network Demonstrations.nnetnnobsolete - (No table of contents file)toolboxoptim - Optimization Toolboxtoolboxpde - Partial Differential Equation Toolbox.toolboxreqmgt - Requirements M
13、anagement Interface.toolboxrptgen - MATLAB Report Generatortoolboxruntime - MATLAB Runtime Server Development Kit toolboxsplines - Spline Toolbox.toolboxstats - Statistics Toolboxtoolboxsymbolic - Symbolic Math Toolbox.webserverwebserver - MATLAB Web Server.webserverwsdemos - (No table of contents f
14、ile)matlab6.5work - (No table of contents file)For more help on directory/topic, type “help topic“.For command syntax information, type “help syntax“.图形如图所示2 。1-1 .绘制正弦曲线和余弦曲线。代码:x=0:0.5:360*pi/180;plot(x,sin(x),x,cos(x);图形如图所示1-2 求方程 3x 4+7x 3+9x2-23=0 的全部根。代码:p=3,7,9,0,-23;x=roots(p)实验结果:x =-1.885
15、7 -0.7604 + 1.7916i4-0.7604 - 1.7916i1.0732 1-3 求积分 xln(1+x)dx.代码:quad(x.*log(1+x),0,1) 实验结果:ans =1/41-4 求解线性方程组 2x-3y+z=48x+3y+2z=245x+yy-9z=17代码:a=2,-3,1;8,3,2;45,1,-9;b =4;2;17;x=inv(a)*b实验结果:x =0.4784-0.87930.4054(1).代码:x=0:0.01:1;y=sin(2*pi*x);plot(x,y,0,1,0,0,0,1-1,1)图形如示(2)代码:p=1,0,0,8,;x=roo
16、ts(p)实验结果:x =-1.0000 + 1.7321i-1.0000 - 1.7321i2.0000 3. help invINV Matrix inverse.INV(X) is the inverse of the square matrix X.A warning message is printed if X is badly scaled ornearly singular.See also SLASH, PINV, COND, CONDEST, LSQNONNEG, LSCOV.Overloaded methodshelp idmodel/inv.mhelp sym/inv.
17、mhelp plot5PLOT 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
18、 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 withPLOT(X,Y,S) where S is a character string made from one elementfrom any or all the following 3 columns:b blue
19、 . point - solidg green o circle : dottedr red x x-mark -. dashdot c cyan + plus - dashed m magenta * stary yellow s squarek black d diamondv triangle (down) triangle (up)triangle (right)p pentagramh hexagramFor example, PLOT(X,Y,c+:) plots a cyan dotted line with a plus at each data point; PLOT(X,Y
20、,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 bythe (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 asolid yellow lin
21、e interpolating green circles at the data points.The PLOT command, if no color is specified, makes automatic use ofthe colors specified by the axes ColorOrder property. The defaultColorOrder is listed in the table above for color systems where thedefault is blue for one line, and for multiple lines,
22、 to cycle6through the first six colors in the table. For monochrome systems,PLOT cycles over the axes LineStyleOrder property.PLOT returns a column vector of handles to LINE objects, onehandle per line. The X,Y pairs, or X,Y,S triples, can be followed by parameter/value pairs to specify additional p
23、roperties of the lines.See also SEMILOGX, SEMILOGY, LOGLOG, PLOTYY, GRID, CLF, CLC, TITLE,XLABEL, YLABEL, AXIS, AXES, HOLD, COLORDEF, LEGEND, SUBPLOT, STEM.Overloaded methodshelp cfit/plot.mhelp iddata/plot.mhelp idmodel/plot.m help maxMAX Largest component.For vectors, MAX(X) is the largest element
24、 in X. For matrices,MAX(X) is a row vector containing the maximum element from eachcolumn. For N-D arrays, MAX(X) operates along the firstnon-singleton dimension.Y,I = MAX(X) returns the indices of the maximum values in vector I.If the values along the first non-singleton dimension contain morethan
25、one maximal element, the index of the first one is returned.MAX(X,Y) returns an array the same size as X and Y with thelargest elements taken from X or Y. Either one can be a scalar.Y,I = MAX(X,DIM) operates along the dimension DIM. When complex, the magnitude MAX(ABS(X) is used, and the angleANGLE(
26、X) is ignored. NaNs are ignored when computing the maximum.Example: If X = 2 8 4 then max(X,1) is 7 8 9,7 3 9max(X,2) is 8 and max(X,5) is 5 8 59, 7 5 9.7See also MIN, MEDIAN, MEAN, SORT. help roundROUND Round towards nearest integer.ROUND(X) rounds the elements of X to the nearest integers.See also
27、 FLOOR, CEIL, FIX8五、思考与练习1、help 命令和 lookfor 命令有什么区别?2、什么是工作空间?假定有变量 A 与 B 存在于工作空间中,如何用命令保存这两个变量?下次重新进入 MATLAB 后,又如何装载这两个变量?答:1.help 命令只搜索那些与关键字完全匹配的结果,lookfor 命令对搜索范围内的 M 文件进行关键字搜索,条件比较宽松。2.工作空间是 MATLAB 用于存储各种变量和结果的内存结果。 在操作界面输入 save a 和 save b ,下次要用的时候 输入 load a 和 load b报告评分:指导教师签字: 批阅日期: 注意: 实验报告以纸质文档形式上交。实验报告将记入平时成绩; 每次实验开始时,交上一次的实验报告,否则将扣除此次实验成绩。