用Add Folder.按钮可以将某一目录加入搜索路径,选择Add with Subfolder.按钮可将选中目录的子目录也包括在搜索路径中。 8.内存数组编辑器:(Array Editor) 提供对数值型或字符型二维数组的显示和编辑功能,对其他数据类型 都不能编辑。通过工作空间窗口打开所选的变量时,该编辑器启动。(图示、 操作演示) 9.帮助浏览器:(Help Browser) (1)帮助浏览器:提供方便快捷的帮助信息获取途径和图文并茂的帮助内 容,MATLAB7.0是通过勾选Desktop菜单中的Help选项打开一个独立的 交互式帮助浏览器。 (2)help命令:在命令窗口输入help命令,也是MATLAB寻找在线帮 助的一种方便而快捷的方式。(图示、操作演示) 例L.hlp(列出主要的帮助主题) HELP topics: matlab\general General purpose commands. matlablops Operators and special characters matlabllang Programming language constructs matlablelmat Elementary matrices and matrix manipulation matlablelfun Elementary math functions. matlab\specfun Specialized math functions. matlab\matfun Matrix functions-numerical linear algebra. matlab\datafun Data analysis and Fourier transforms. matlablaudio Audio support. matlab\polyfun Interpolation and polynomials. matlab\funfun Function functions and ODE solvers matlab\sparfun Sparse matrices. matlab\graph2d Two dimensional graphs. matlab\graph3d Three dimensional graphs matlab\specgraph Specialized graphs
用 Add Folder.按钮可以将某一目录加入搜索路径,选择 Add with Subfolder.按钮可将选中目录的子目录也包括在搜索路径中。 8.内存数组编辑器:(Array Editor) 提供对数值型或字符型二维数组的显示和编辑功能,对其他数据类型 都不能编辑。通过工作空间窗口打开所选的变量时,该编辑器启动。(图示、 操作演示) 9.帮助浏览器:(Help Browser) (1)帮助浏览器:提供方便快捷的帮助信息获取途径和图文并茂的帮助内 容,MATLAB7.0 是通过勾选 Desktop 菜单中的 Help 选项打开一个独立的 交互式帮助浏览器。 (2)help 命令:在命令窗口输入 help 命令,也是 MATLAB 寻找在线帮 助的一种方便而快捷的方式。(图示、操作演示) 例 1. help (列出主要的帮助主题) HELP topics: matlab\general - General purpose commands. matlab\ops - Operators and special characters. matlab\lang - Programming language constructs. matlab\elmat - Elementary matrices and matrix manipulation. matlab\elfun - Elementary math functions. matlab\specfun - Specialized math functions. matlab\matfun - Matrix functions - numerical linear algebra. matlab\datafun - Data analysis and Fourier transforms. matlab\audio - Audio support. matlab\polyfun - Interpolation and polynomials. matlab\funfun - Function functions and ODE solvers. matlab\sparfun - Sparse matrices. matlab\graph2d - Two dimensional graphs. matlab\graph3d - Three dimensional graphs. matlab\specgraph - Specialized graphs
例2.help exp(列出指定主题下的函数说明) EXP Exponential. EXP(X)is the exponential of the elements of X,e to the X. For complex Z=X+i*Y.EXP(Z)=EXP(X)*(COS(Y)+i*SIN(Y)). See also LOG.LOG10.EXPM.EXPINT. Overloaded methods help sym/exp.m help fints/exp.m help demtseries/exp.m (3)lookfor命令:(lookfor commend)可以根据用户提供的完整或不完 整的关键词,搜索出一组与之相关的命令或函数。(图示、操作演示) 例:lookfor integral ELLIPKE Complete elliptic integral. EXPINT Exponential integral function. DBLQUAD Numerically evaluate double integral. QUAD Numerically evaluate integral,adaptive Simpson quadrature. QUAD8 Numerically evaluate integral,higher order method. QUADL Numerically evaluate integral,adaptive Lobatto quadrature COSINT Cosine integral function SININT Sine integral function. ASSEMA Assembles area integral contributions in a PDE problem COSINT Cosine integral function FOURIER Fourier integral transform. IFOURIER Inverse Fourier integral transform. SININT Sine integral function. BLKPIDCON The output of the block is the sum of proportional,integral and (4)模糊查询:(fuzzy Inquiry)用户只须输入命令的前几个字母,然后键 入Tab键MATLAB就会列出所有以这个字母开始的命令。(图示、操作演 示)
例 2. help exp (列出指定主题下的函数说明) EXP Exponential. EXP(X) is the exponential of the elements of X, e to the X. For complex Z=X+i*Y, EXP(Z) = EXP(X)*(COS(Y)+i*SIN(Y)). See also LOG, LOG10, EXPM, EXPINT. Overloaded methods help sym/exp.m help fints/exp.m help demtseries/exp.m (3)lookfor 命令:(lookfor commend) 可以根据用户提供的完整或不完 整的关键词,搜索出一组与之相关的命令或函数。(图示、操作演示) 例:lookfor integral ELLIPKE Complete elliptic integral. EXPINT Exponential integral function. DBLQUAD Numerically evaluate double integral. QUAD Numerically evaluate integral, adaptive Simpson quadrature. QUAD8 Numerically evaluate integral, higher order method. QUADL Numerically evaluate integral, adaptive Lobatto quadrature. COSINT Cosine integral function. SININT Sine integral function. ASSEMA Assembles area integral contributions in a PDE problem. COSINT Cosine integral function. FOURIER Fourier integral transform. IFOURIER Inverse Fourier integral transform. SININT Sine integral function. BLKPIDCON The output of the block is the sum of proportional, integral and (4)模糊查询:(fuzzy Inquiry) 用户只须输入命令的前几个字母,然后键 入 Tab 键 MATLAB 就会列出所有以这个字母开始的命令。(图示、操作演 示)
例:在命令窗口键入plot然后按Tab键,可得各种以为字头的命令: plot plotbr plotes plotmap plotperf plottr plot3 plotchar plotfa plotmatrix plotpv plotv plot3m ploteach plotfis plotmf plotscale plotvec plotall plotedit plotfrsp plotnic plotsm plotyy plotbintree plotep plotlr plotnyq plotsom plotbode ploterr plotm plotpc plotstep 四.MATLAB的基本操作 1.简单矩阵的建立(matrix setting) Matrix:A kind of special type of data structure,most function and operation of MATLAB were based on it.It is a set of numbers arranged using a rectangular grid of rows and columns. *Scalar:It is just a single number and it can be considered as a special matrix with one row and one column. *Vector:It is a series of numbers arranged in a row or a column;Also we can refer to the vector as a special matrix with one row or one column.It may be called a row vector or a column vector MATLAB以矩阵为基本运算对象,标量可看作1X1的矩阵,矢量看 作n×1或1×n的矩阵。 输入方式:(Input Mode)) (I)以直接列出元素的形式输入:(simply initializing matrices by the method to explicitly lists the values)把矩阵元素直接排列到方括号[]中,每 行内的元素用逗号或空格分开,行与行之间用分号隔开。 例:a=123;246:8351或a=1,2,3:2,4,6;8,3,5 大矩阵可分行输入: a=123 246 8351 (2).通过语句和函数产生:(Creating a new matrix from a existing matrix throw MATLAB language or functions)对于已经存在的矩阵,可用函数
例: 在命令窗口键入 plot 然后按 Tab 键,可得各种以为字头的命令: plot plotbr plotes plotmap plotperf plottr plot3 plotchar plotfa plotmatrix plotpv plotv plot3m ploteach plotfis plotmf plotscale plotvec plotall plotedit plotfrsp plotnic plotsm plotyy plotbintree plotep plotlr plotnyq plotsom plotbode ploterr plotm plotpc plotstep 四.MATLAB 的基本操作 1.简单矩阵的建立(matrix setting) Matrix: A kind of special type of data structure, most function and operation of MATLAB were based on it. It is a set of numbers arranged using a rectangular grid of rows and columns. *Scalar: It is just a single number and it can be considered as a special matrix with one row and one column. *Vector: It is a series of numbers arranged in a row or a column; Also we can refer to the vector as a special matrix with one row or one column. It may be called a row vector or a column vector. MATLAB 以矩阵为基本运算对象,标量可看作 1×1 的矩阵,矢量看 作 n×1 或 1×n 的矩阵。 输入方式:(Input Mode) (1)以直接列出元素的形式输入:(simply initializing matrices by the method to explicitly lists the values )把矩阵元素直接排列到方括号[ ]中,每 行内的元素用逗号或空格分开,行与行之间用分号隔开。 例: a=[1 2 3;2 4 6;8 3 5] 或 a=[1, 2, 3;2, 4 ,6;8, 3 ,5] 大矩阵可分行输入: a=[1 2 3 2 4 6 8 3 5] (2). 通过语句和函数产生:(Creating a new matrix from a existing matrix throw MATLAB language or functions) 对于已经存在的矩阵,可用函数
或表达式产生新的矩阵。例如:矩阵a和x己存在,利用y=si(x)和 c=a+0.1*(1+a/2)命令将产生新矩阵y和c。 利用内部语句和函数可以快速产生一些特别有用的工具矩阵,如全0 阵,全1阵,单位阵,随机阵等。 (3),在m文件中创建矩阵:(Creating a matrix within the M file)通过建 立MATLAB的M文件可完成矩阵的输入,如建立B.m的文件,内容为: B-=342;135;643 或B=342 135 6431 则在命令窗口中使用B命令语句可以调用B矩阵。 (4)从外部的数据文件中装入:(Read the Matrix from external data file) 利用load或fread命令可以读取MATLAB早期版本产生的矩阵,也可 读取有其他应用程序产生的数据(或矩阵)。 2.矩阵元素(Element of matrix:Any kind of expression can be used as a matrix element) 可以用任何形式的表达式来充当矩阵元素,如: x-1.3sqrt3)(1+2+3)*4/5 将得到矩阵: X= -1.30001.73214.8000 可以定义或修改矩阵中某一元素,如操作:x(⑤)=as(x(1)得一个新矩阵 X- -1.30001.7321 4.800001.3000 可以用小矩阵构成大矩阵,如: a=123;456;789; ca10,11,12结果为: c= 123 456 7 8 9
或表达式产生新的矩阵。 例如: 矩阵 a 和 x 已存在,利用 y=sin(x) 和 c=a+0.1*(1+a/2) 命令将产生新矩阵 y 和 c。 利用内部语句和函数可以快速产生一些特别有用的工具矩阵,如全 0 阵,全 1 阵,单位阵,随机阵等。 (3).在 m 文件中创建矩阵:(Creating a matrix within the M file)通过建 立 MATLAB 的 M 文件可完成矩阵的输入,如建立 B.m 的文件,内容为: B=[3 4 2;1 3 5;6 4 3] 或 B=[3 4 2 1 3 5 6 4 3] 则在命令窗口中使用 B 命令语句可以调用 B 矩阵。 (4) 从外部的数据文件中装入:(Read the Matrix from external data file) 利用 load 或 fread 命令可以读取 MATLAB 早期版本产生的矩阵,也可 读取有其他应用程序产生的数据(或矩阵)。 2.矩阵元素(Element of matrix: Any kind of expression can be used as a matrix element) 可以用任何形式的表达式来充当矩阵元素,如: x=[-1.3 sqrt(3) (1+2+3)*4/5] 将得到矩阵: x= -1.3000 1.7321 4.8000 可以定义或修改矩阵中某一元素,如操作: x(5)=abs(x(1)) 得一个新矩阵 x= -1.3000 1.7321 4.8000 0 1.3000 可以用小矩阵构成大矩阵, 如: a=[1 2 3;4 5 6;7 8 9]; c=[a;[10,11,12]] 结果为: c= 1 2 3 4 5 6 7 8 9
101112 或r101112l; c=Ia;r] 可得同样矩阵c= 123 456 789 101112 可使用”:"(colon)从大矩阵中抽取小矩阵,(withdraw a small matrix from a big matrix)如: d=c(1:3,:)意为抽取一到三行的各列,结果为: d= 123 456 789 e=c(,1:2)意为抽取一到二列的各行,结果为: 12 45 78 1011 3.语句与变量(Statementand variable) MATLAB语句的常用格式:.变量-表达式(;)(variable-expression(,》 或简化为:表达式(;) 表达式可以由运算符(Operator)、特殊字符(special character)、函数名 (function name)、变量名(variable name)等组成,表达式的结果为一矩阵, 它赋给左边的变量。如省略变量名和“=”,则自动产生一个名为as的变 量,如: 1900/81结果为: ans- 23.45684568
10 11 12 或 r=[ 10 11 12 ]; c=[ a;r ] 可得同样矩阵 c= 1 2 3 4 5 6 7 8 9 10 11 12 可使用”:”(colon) 从大矩阵中抽取小矩阵, (withdraw a small matrix from a big matrix)如: d=c(1:3,:) 意为抽取一到三行的各列, 结果为: d= 1 2 3 4 5 6 7 8 9 e=c(:,1:2) 意为抽取一到二列的各行, 结果为: 1 2 4 5 7 8 10 11 3.语句与变量(Statement and variable) MATLAB 语句的常用格式: 变量=表达式(;) (variable=expression(;)) 或简化为: 表达式(;) 表达式可以由运算符(Operator)、特殊字符(special character)、函数名 (function name)、变量名(variable name) 等组成,表达式的结果为一矩阵, 它赋给左边的变量。如省略变量名和“=”,则自动产生一个名为 ans 的变 量, 如: 1900/81 结果为: ans= 23.4568 4568