麻省理工matlab常用口令
- 格式:pdf
- 大小:181.90 KB
- 文档页数:19
matlab常用指令MATLAB是一款非常实用的科学计算软件,在使用过程中,一些常用的指令是非常必要的。
在本篇文章中,我们将会介绍MATLAB常用指令,以使你更加熟练掌握MATLAB的使用。
一、基本数学运算+ 加- 减* 乘/ 除^ 幂(指数)sqrt 平方根exp 取指数log 取自然对数log10 取以10为底的对数sin 正弦cos 余弦tan 正切asin 反正弦acos 反余弦atan 反正切abs 绝对值rem 模运算fix 向零取整floor 向负无穷取整ceil 向正无穷取整round 四舍五入mod 取摸余数二、变量与矩阵1、赋值:通过等号将数值赋给变量,如:a=3;b=2.1;c=2+3i;2、数列:建立一个等差数组,例如:d=1:10; %1到10的等差数列e=linspace(0,2*pi,100); %0到2*pi之间的100个等间距点 a=[1 2 3;4 5 6;7 8 9];b=zeros(2,3);c=ones(3,2);d=rand(3,3);e=eye(4);4、矩阵元素操作:通过下标访问矩阵中的元素,例如:a(1,2) %输出a矩阵第一行第二列的元素b(2,3)=7 %将b矩阵第二行第三列的元素赋为75、矩阵运算:矩阵加减乘除,如:a+b %对应元素相加a-b %对应元素相减a*b %矩阵乘法a/b %矩阵除法a' %矩阵转置6、矩阵函数:除了使用基本操作外,还能使用各种矩阵相关函数完成矩阵计算,例如:inv(a) %矩阵求逆det(a) %矩阵求行列式trace(a) %矩阵求迹eig(a) %求特征值rank(a) %矩阵的秩size(a) %返回矩阵的大小max(a) %求矩阵元素最大值min(a) %求矩阵元素最小值sum(a) %求矩阵元素的和prod(a) %求矩阵所有元素的乘积mean(a) %求矩阵元素的平均值三、绘图1、二维绘图:绘制二维函数的曲线、散点图等,例如:x=linspace(-3,3,100); %生成-3到3之间的100个等间距点y=sin(x);plot(x,y); %绘制正弦函数曲线plot(x,y,'r--'); %绘制红色的正弦函数曲线,形状为虚线xlabel('x values');ylabel('y values');title('sine function');grid on;四、数据处理1、数据导入:在MATLAB中,可以通过各种方式将数据导入,如:a=load('filename.txt'); %从文件中载入数据b=xlsread('filename.xls'); %从Excel文件中载入数据五、编程1、条件语句:通过条件语句实现程序的分支结构,例如:if(a<0)disp('a is negative');elseif(a==0)disp('a is zero');elsedisp('a is positive');endfor i=1:10disp(i);end3、函数:在MATLAB中,可以自定义函数,函数调用格式为:function [out1,out2,...]=function_name(in1,in2,...)%函数说明%计算过程end4、脚本:在MATLAB中,脚本是一些命令或函数的集合,可以将脚本保存到文件中执行,例如:%脚本说明a=1;b=2;c=a+b;disp(c);以上便是MATLAB一些常用指令的详细介绍。
MATLAB数值计算简单词汇:1、简单命令词汇:1.1 特殊常量和变量表1.2 数学函数1.3 M函数格式为:1.4 创建简单的数组:linspace、logspace:x=linspace(first,last,n) 创建从first开始,到last结束,有n个元素的等分隔行向量;x=logspace(first,last,n) 创建从first开始,到last结束,有n个元素的对数分隔行向量。
1.5 MA TLAB提供三种决策或控制流结构:1.5.1 for循环:1.5.3 if-else-end结构:(1)有一个选择的一般形式是:(2)有三个或更多的选择的一般形式是:1.6 简单高级编程简单用词:1.7 在线帮助:1.8 文件管理:1.9基础符号运算函数:1.10 数字显示2、简单作图命令词汇:2.1 平面曲线图:plot:plot(X,Y,S)2.2 符号函数(显函数、隐函数和参数方程)画图(1)ezplotezplot('f(x)',[a,b]) 表示在a<x<b绘制显函数f=f(x)的函数图。
ezplot('f(x,y)',[xmin,xmax,ymin,ymax])表示在区间xmin<x<xmax和ymin<y<ymax绘制隐函数f(x,y)=0的函数图。
ezplot(' x(t) ', ' y(t) ',[tmin,tmax])表示在区间tmin<t<tmax 绘制参数方程x=x(t),y=y(t)的函数图。
(2)fplotfplot('fun',lims)表示绘制字符串fun指定的函数在lims=[xmin,xmax]的图形2.3 空间曲线(1)一条曲线plot3(x,y,z,s)其中x,y,z为n维向量(2)多条曲线plot3(x,y,z)其中x,y,z是都是m×n矩阵2.4空间曲面(1)surf(x,y,z)画出数据点(x,y,z)表示的曲面(2)mesh(x,y,z)画网格曲面,2.5图形处理:2.5.1 在图形上加格栅、图例和标注(1)grid on加格栅在当前图上;grid off删除格栅。
记住再多的口令,不会用于实践,照样没用!如果连基本知识都记不住,想用亦是没门Matlab的基本运算在在命令窗口中若输入数据太长,可通过在行尾加上三个句号( ... )来续行在命令窗口中若输入Ctrl + C 终止正在执行中命令在命令历史窗口中双击所记录命令可使它再次执行使用format可以控制数据以不同格式进行显示format short 短格式3.1416format short e 短格式科学格式3.1416e+00format long 长格式3.141592653589793format long e 长格式科学格式3.141592653589793e+00MATLAB的变量是以double的精度进行运算和存储,无需进行指定MATLAB中变量名规则变量名中的字符可以是英文字母、数字或者下划线变量名中的字符间不可留空格变量名中的第一个字符必须为字母英文字母区分大小写无法改变的特殊变量有pi,inf或Inf,eps,NaN或nan,i或j等特例:使用pi的完整值时需要用sym('pi')用input 函数从键盘输入初始化变量,例如:in1 = input('enter data:');in2 = input('enter data:','s')字符串吧?显示disp( sprintf ( '%d is %s|n',n,r)) ;常用简单函数1 格式:Y = abs(X)功能:数值的绝对值与复数的幅值,变字符为ASCI码2 格式:Y = exp(X)功能:求以e为底数的指数运算,即Y = eX。
若X为复数x + yi,则eX = ex(cos(y) + isin(y))3 格式:z = lcm(x,y)相反 gcd功能:计算两个正整数x和y的最小公倍数4 格式:实部x = real(Z) 虚部y=imag(z) 共轭z1=conj(z)功能:返回输入复数Z的实数部分。
matlab基本命令
MATLAB是一种广泛使用的数学软件,用于数据分析、图形绘制和科
学计算。
下面是一些MATLAB基本命令,这些命令有助于您快速入门。
1.创建一个向量或矩阵:
a = [1 2 3 4]
b = [3;4;5;2]
2.创建一个特定范围的向量或矩阵:
c = 1:5
d = 2:2:8
e = linspace(0,1,11)
3.访问矩阵中的元素
a(2) //访问a中的第二个元素
b(3,2) // 访问b中的第三行第二列元素
4.矩阵操作
f = a + b
g = a - b
h = a * b
5.数学函数
x = sin(3.1416)
y = sqrt(25)
z = exp(2)
6.图形绘制
x = linspace(0,2*pi,100)
y = sin(x)
plot(x,y)
这些是MATLAB基本命令的一些示例。
学习这些命令是快速掌握MATLAB的关键。
做好练习,加深对这些命令的理解和运用,让您能够轻松地处理各种数据并进行数学计算和可视化。
matable常用指令集ABS absolute values, modulus, and ASCII code values of characters ACOS inverse cosineAcosh inverse hyperbolic cosineAcot arccotAcoth inverse cotangentACSC arccscAcsch inverse cosecantAlign starts the graphic object geometry location toolAll all elements are nonzero and trueAngle phase angleDefault variable name for the result of the ANS expression calculationAny all elements are not whole zero to be trueArea surface area graphArgnames function M file quantity nameASEC cut anywayAsech inverse hyperbolic secantAsin anti sineAsinh inverse hyperbolic sineAssignin assign values to variablesAtan tangentAtan2 four quadrant inverse tangentAtanh inverse hyperbolic tangentAutumn red, yellow and autumn sceneryAxes creates low-level instructions for axis objectsThe axis controls the axis, scale, and style of the high-level instructionsBBar two-dimensional histogramBar3 3D histogramBar3h 3D horizontal histogramBarh two-dimensional horizontal histogramBase2dec X decimal to decimalBIN2DEC binary to decimalBlanks creates a string of spacesBone blue black and white color map arrayBox frame coordinate axisBreak, while, or for ring interrupt instructionBrighten brightness controlCCapture the current graphics before capture (version 3)Cart2pol rectangular coordinates change to polar or cylindrical coordinatesCart2sph rectangular coordinates into spherical coordinates Cat string into a high dimensional arrayCaxis color scale calibrationCD specifies the current directoryCdedit starts the user menu, the control callback function design toolCdf2rdf complex eigenvalue diagonal matrix turns into real block diagonal matrixCeil rounding toward positive infinityCell creates a cell arrayThe cell2struct cell array is converted to an array of frames Celldisp shows the contents of the cell arrayInternal structure diagram of cellplot cell arrayChar converts values, symbols, and inline classes to character objectsCumulative probability function of chi2cdf distributionInverse cumulative probability function of chi2inv distribution Chi2pdf distribution probability density functionChi2rnd distribution random number generatorChol Cholesky decompositionClabel equipotential line identifierCLA clears the current axisClass learns object categories or creates objectsCLC clear instruction windowClear clears memory variables and functionsCLF clear drawing objectsClock clockColorcube three color crossed color map matrixColordef sets color default valuesColormap color chartThe base of a colspace column spaceClose closes the specified windowColperm column sort permutation vectorComet comet like trajectory mapComet3 3D comet trajectory mapCompass ray mapCompose for composite functionsCond (inverse) condition numberCondeig calculates eigenvalues and eigenvectors, and gives the condition numberCondest van -1 conditional number estimationConj complex conjugateContour equipotential lineContourf coloring equipotential lineContour3 three-dimensional equipotential lineContourslice 4D slice equipotential line mapMultiplicative and convolution of conv polynomialsCool cool black and blue picturesCopper bronze toning chartCos cosine双曲余弦双曲余弦床余切又称双曲余切cplxpair复数共轭成对排列中信建投余割双曲余割双曲余割元素累计和Cumsumcumtrapz累计梯形积分缸创建圆柱Ddblquad二重数值积分交易分配宗量deblank删去串尾部的空格符dec2base十进制转换为X进制dec2bin十进制转换为二进制dec2hex十进制转换为十六进制deconv多项式除、解卷Delaunay三角三角剖分del2离散拉普拉斯差分matlab演示演示挪威行列式诊断矩阵对角元素提取、创建对角阵MATLAB指令窗文本内容记录日记不同的数值差分、符号微分数字符号计算中设置符号数值的精度你目录列表显示显示数组显示显示对象内容的重载函数dlinmod离散系统的线性化模型dmperm矩阵Dulmage门德尔松分解DOS执行DOS指令并返回结果双把其他类型对象转换为双精度数值刷新屏幕更新事件队列强迫MATLAB刷新屏幕符号计算解微分方程DSOLVEE我文件被执行指令的显示回声编辑启动M文件编辑器本求特征值和特征向量eigs求指定的几个特征值对于等结构体的结尾元素下标端控制流EPS浮点相对精度错误显示出错信息并中断执行错误发生后程序是否继续执行的控制ErrorTrap ERF误差函数误差补函数erfcerfcx刻度误差补函数erfinv逆误差函数误差线带误差限的曲线图etreeplot画消去树eval串演算指令evalin跨空间串演算指令存在检查变量或函数是否已定义出口退出MATLAB环境口指数函数扩大符号计算中的展开操作expint指数积分函数expm常用矩阵指数函数expm1 Pade法求矩阵指数泰勒法求矩阵指数expm2expm3特征值分解法求矩阵指数眼单位阵ezcontour画等位线的简捷指令ezcontourf画填色等位线的简捷指令ezgraph3画表面图的通用简捷指令ezmesh画网线图的简捷指令ezmeshc画带等位线的网线图的简捷指令ezplot画二维曲线的简捷指令ezplot3画三维曲线的简捷指令ezpolar画极坐标图的简捷指令ezsurf画表面图的简捷指令ezsurfc画带等位线的表面图的简捷指令F因子符号计算的因式分解羽毛羽毛图反馈反馈连接费瓦执行由串指定的函数离散变换傅里叶变换二维离散傅里叶变换fft2Fftn high dimensional discrete Fourier transformSpectrum of fftshift DC component alignmentFieldnames framework domain nameFigure creates graphical windowsFill3 3D polygon color mapFind looking for nonzero element indexFindobj looks for the object graph handle with the specified attributeFindstr looks for initial characters for short stringsThe findsym machine determines the symbolic variables in memory Inverse function in Finverse symbolic computationFix rounded to zeroFlag red blue black color chart staggered arrayThe left and right flip of the fliplr matrixFlip up and down the flipud matrixThe flipdim matrix is flipped along the specified dimensionThe floor negative infinite integralFlops floating-point arithmetic timesPresentation data provided by flow MatlabFmin finding the minimum point of a single variable nonlinear function (old version)Fminbnd to find the minimum point of a nonlinear function of a single variableFmins uses the simplex variable function minima (old version) Fminunc quasi Newton method variable function minimum pointFminsearch uses the simplex variable function minimaDerivation of spline function by fnderFnint uses spline functions to obtain integralsFnval calculates the value of any point in the spline function Fnplt draw spline function graphFopen open external fileFor constitutes the for ringFormat set output formatFourier Fourier transformFplot drawing instructionsFprintf settings display formatFREAD reads binary data from a fileFsolve for the zeros of multivariate functionsFull transforms sparse matrices into non sparse matricesFunm calculates general matrix functionsFuntool function calculator graphical user interfaceFzero for the zeros of nonlinear functions of a single variableGGamma functionGammainc incomplete functionThe logarithm of the gammaln functionGCA gets the current axis handleGcbo gets the object handle that is executing the callback GCF gets the handle of the current graph objectGCO gets the current object handleGeomean geometric meanGet learns object propertiesGetfield learns the domain of the frame arrayGetframe gets the frame screen for the movieGinput gets data from the graphical windowGlobal defines global variablesAccording to the study of the principle of drawing gplot Gradient approximation gradientGray black and white grayscaleGrid sub gridGriddata regularization data and surface fittingGtext place annotation text by mouseGuide starts graphical user interface interactive design tools HHarmmean harmonic meanHelp online helpHelpwin interactive online helpHelpdesk opens hypertext User GuideHEX2DEC sixteen decimal to decimalHex2num sixteen hexadecimal converted to floating-point numbers Hidden fluoroscopy and blanking switchHilb Hilbert matrixHist frequency calculation or frequency histogramHistc endpoint location frequency histogramFrequency histograms of histfit with normal fittingSwitch hold map redraw the currentHorner decomposes into nested formFigure hot black whiteHSV saturation color diagramIIf-else-elseif conditional branching structureIFFT discrete Fourier inverse transformIfft2 two dimensional discrete Fourier inverse transformIfftn high dimensional discrete Fourier inverse transformThe inverse operation of the spectrum in the ifftshift DC component pairIfourier Fourier inverse transformI, J, default dummy unit variableIlaplace Laplace inverse transformImag complex imaginary partImage display imageImagesc displays brightness imagesImfinfo get graphic file informationImread reads images from filesImwrite putImwrite writes images into documentsInd2sub single subscript is converted to multi index Inf infinityInfo MathWorks company addressInline constructs inline function objectsInmem lists the name of the function in memoryInput prompts the user for inputInputname enter the quantum nameInt Symbolic IntegrationInt2str converts an integer array into a string array Interp1 one-dimensional interpolationInterp2 two-dimensional interpolationInterp3 3D interpolationInterpn N dimensional interpolationInterpft uses FFT interpolationIntro Matlab comes with an entry GuideInv inverse matrixExact inverse of invhilb Hilbert matrixIpermute generalized inverse transpositionIsa tests whether objects of the given class are givenIschar is true if it is a stringIsequal is true if two arrays are the sameIsempty is true if it is emptyIsfinite if all elements are finite, then trueIsfield is true if the domain is constructedIsglobal is true if the global variable is trueIshandle is true if it is a graphical handleIshold true if the current graph is in reserveIsieee if the computer executes the IEEE rule, that's true Isinf is true if it is infiniteIsletter if the English alphabet is trueIslogical is true if it is a logical arrayDoes the ismember check belong to the specified set? IsNaN if the non number is trueIsNumeric is true if it is an array of valuesIsobject is true if it is an objectIsprime is true if the prime number is trueIsreal is true if it is realIsspace if the space is trueIssparse is true if the sparse matrix is trueIsstruct if the framework is trueIsstudent if Matlab, student edition is trueIztrans symbolic computation, Z inverse transformJ, KJacobian matrix in Jacobian symbolic computationJet blue head, red tail, saturated colorJordan standard type is obtained in Jordan symbolic computation The keyboard keyboard gains controlAn array generated by the Kron Kronecker multiplication ruleLLaplace Laplace transformLasterr displays the latest error messagesLastwarn displays the latest alert informationLeastsq solving nonlinear least squares problems (old edition) Legend graphic legendLighting lighting modeLine creates line objectsLines uses plot to draw line colorLinmod obtains a linearized model of the continuous system Linmod2 gets linearized model of continuous systemLinspace linear equal vectorNatural logarithm of LN matrixLoad reads variables from the MAT fileLog natural logarithmLog10 common logarithmLog2 is the logarithm of 2Loglog double logarithmic scale graphicsLogm matrix logarithmLogspace logarithmic index vectorLookfor searches the M file by keywordLower converts to lowercase lettersLsqnonlin solving nonlinear least squares problemsLu LU decompositionMMad mean absolute deviationMagic magic cubeMaple, &nb, sp; operates Maple format instructionsMat2str converts a numeric array into an array of input morphological stringsMaterial material reflection modeMax looks for the largest element in the vectorMbuild generates a preset instruction for the EXE file compilation environmentMCC creates compiler directives for MEX or EXE filesMean to find the mean of vector elementsMedian medianMenuedit starts the interactive editing tool for designing user menusMesh net diagramMeshz screen meshMeshgrid produces a lattice matrixMethods learned all the method functions defined for the specified classMex generates a preset instruction for the MEX file compilation environmentMfunlis list of MAPLE classical functions that can be computed by mfunMhelp leads Maple's online helpMin find the smallest element in the vectorMKDIR create directoryThe clarity of mkpp piecewise polynomial dataMod modular operationPagination display of contents in more instruction windowMovie shows film animationMoviein video frame picture memory presetMtaylor symbolic computation; multivariable Taylor seriesexpansionNNdims for array dimensionNaN non number (predefined) variablesNargchk input quantum validationNargin function input argumentsNargout function output argumentsNdgrid has high dimensional lattice matrixNewplot prepares the new default diagram, axisNextpow2 takes the nearest larger 2 powerThe total number of nonzero elements of the nnz matrixNonzero elements of the nonzeros matrixNorm matrix or vector normNormcdf normal distribution cumulative probability density function Normest estimation of matrix 2 normNorminv normal distribution; inverse cumulative probability density functionNormpdf normal distribution probability density functionNormrnd normal random number generatorNotebook starts the integration environment for Matlab and Word Null null spaceNum2str converts a non integer array into a stringNumden obtains the lowest common denominator and thecorresponding molecular expressionNzmax specifies the memory needed to store nonzero elementsOOde1 non Stiff differential equation variable step solverOde15s Stiff differential equation variable step solverOde23t moderately Stiff differential equation solverOde23tb Stiff differential equation solverOde45 non Stiff differential equation variable step solverOdefile ODE file templateOdeget is informed of the ODE options and sets parametersTwo dimensional phase plane diagram of odephas2 ODE output function Three dimensional phase space diagram of odephas3 ODE outputfunctionTime trajectory diagram of odeplot ODE output functionOdeprint displays the results in the Matlab instruction windowOdeset creates or overwrites the ODE options schema parametervalueOnes all 1 arrayOptimset creates or overwrites the optional parameter values for optimizing functional instructionsOrient sets the way the graphics are emittedOrth valued space orthogonalizationPPack collects Matlab memory fragments and expands memoryPagedlg brings up the graphical layout dialog boxPatch creates block objectsPath sets the instruction for the Matlab search pathPathtool search path managerPause pausePcode creates a pre interpreted P code filePcolor pseudo colorTypical 3D surfaces provided by peaks MatlabPermute generalized transposePI (predefined variables).Pie two-dimensional pie chartPie3 3D pie chartPink pink graph matrixPINV pseudo inversePlot plane line diagramPlot3 3D line graphScatter diagram of plotmatrix matrixPlotyy double ordinate mapPoissinv Poisson distribution inverse cumulative probability distribution functionPoissrnd Poisson distribution random number generatorPol2cart polar or cylindrical coordinates are converted into Cartesian coordinatesPolar polar diagramThe corresponding polynomial of characteristic polynomial and root set of poly matrixPoly2str displays polynomials in a habitual wayPoly2sym double precision polynomial coefficients are transformed into vector symbolic polynomialsPolyder polynomial derivativePolynomial fitting of polyfit dataPolyval calculates the value of a polynomialPolyvalm computing matrix polynomialPower of pow2 2Ppval computing piecewise polynomialPretty displays symbolic expressions in a habitual way Print print graphics or SIMULINK modelPrintsys displays rational fractions in a customary way Prism spectral color map matrixProcread transport calculation program to MAPLEProfile function file performance evaluatorPropedit graphical object property editorPWD displays the current working directoryQQuad Low order method for numerical integration Numerical calculation of high-order quad8 (QUADL)Quit launches Matlab environmentQuiver two-dimensional directional arrowQuiver3 arrow in 3D directionRRand produces uniformly distributed random numbers Randn produces normally distributed random numbers Randperm random permutation vectorRange sample rangeRank of rank matrixRats rational outputRcond matrix, inverse condition, estimationThe real part of the plural of realReallog calculates the natural logarithm in the real fieldRealpow in the real domain computing powerRealsqrt calculates the square root in the real fieldRealmax maximum positive floating point numberRealmin minimum positive floating point numberRectangle draw a rectangular box"REM for remainderRepmat laying module arrayReshape changes array dimensions and sizesResidue partial fraction expansionReturn returnsRibbon draws the two-dimensional curve into a three-dimensional color chartRmfield delete the field of the frameRoots seeks the root of a polynomialRose number sectorial graphThe rot90 matrix rotates 90 degreesRotate specifies the origin and direction of rotationRotate3d starts the interactive settings feature of the 3D graphics viewRound rounding up the nearest integerThe rref simplified matrix is of trapezoid formRsf2csf real block diagonal matrix is transformed into complex eigenvalue diagonal matrixrsums riemann和ssave 把内存变量保存为文件scatter 散点图scatter3 三维散点图sec 正割sech 双曲正割semilogx x轴对数刻度坐标图semilogy y轴对数刻度坐标图series 串联连接set 设置图形对象属性setfield 设置构架数组的域setstr 将ascii码转换为字符的旧版指令sign 根据符号取值函数符号计算中的符号取值函数 operationsim 运行simulink模型simget 获取simulink模型设置的仿真参数simple 寻找最短形式的符号解help 符号计算中进行简化操作simset 对simulink模型的仿真参数进行设置simulink 启动simulink模块库浏览器sin 正弦one 双曲正弦size 矩阵的大小slice 立体切片图solve 求代数方程的符号解spalloc 为非零元素配置内存sparse 创建稀疏矩阵spconvert 把外部数据转换为稀疏矩阵spdiags 稀疏对角阵spfun 求非零元素的函数值sph2cart 球坐标变为直角坐标sphere 产生球面spinmap 色图彩色的周期变化spline 样条插值spones 用1置换非零元素sprandsym 稀疏随机对称阵sprank 结构秩spring 紫黄调春色图sprintf 把格式数据写成串spy 画稀疏结构图sqrt 平方根sqrtm 方根矩阵squeeze 删去大小为1的 "孤维"按指定格式读串 sscanfstairs 阶梯图std 标准差stem 二维杆图step 阶跃响应指令str2double 串转换为双精度值str2mat 创建多行串数组str2num 串转换为数strcat 接成长串串比较 strcmpstrjust 串对齐strmatch 搜索指定串串中前若干字符比较 strncmp() strrep 串替换while the 寻找第一间隔符前的内容struct 创建构架数组struct2cell 把构架转换为元胞数组strvcat 创建多行串数组sub2ind 多下标转换为单下标subexpr 通过子表达式重写符号对象subplot 创建子图符号计算中的符号变量置换 subs 两子空间夹角 subspacesum 元素和summer 绿黄调夏色图superiorto 设定优先级surf 三维着色表面图surface 创建面对象surfc 带等位线的表面图surfl 带光照的三维表面图surfnorm 空间表面的法线svd 奇异值分解svds 求指定的若干奇异值switch case otherwise 多分支结构sym2poly 符号多项式转变为双精度多项式系数向量symmmd 对称最小度排序symrcm 反向cuthill - mckee排序创建多个符号对象 symstTan tangentTanh hyperbolic tangentTaylortool interactive interface for Taylor approximation analysis Text text annotationTF creates transfer function objectsTic start timerTitle nameTOC turn off timerTrapz trapezoidal method, numerical integrationTreelayout expand trees and forestsTreeplot draw tree diagramTril lower triangular arrayTrim for system balance pointTrimesh irregular grid line graphTrisurf irregular grid surface graph triu, triangular array, try-catch control flow, Try-catch structure, type display, M file UUicontextmenu create live menuUicontrol creates user controlsUIMENU create user menuAnti - clarity of unmkpp piecewise polynomial dataUnwrap natural phase angleUpper converts to uppercase lettersVVar varianceVarargin variable length inputVarargout variable length outputVectorize makes string expressions or inline functionssuitable for Array OperationsAccess to ver version informationVisual angle control of view 3D graphicsVoronoi Voronoi polygonVPA arbitrary precision (symbol class) valueWWarning displays warning messagesWhat lists the files on the current directoryWhatsnew displays the contents of the Readme file in MatlabWhich determines the location of the function and file While ring structure in while control flowWhite all white graph matrixWhitebg specifies the background color of the axisWho lists the variable names in memoryWhos lists detailed information about variables in memory Winter blue and green winter color chartWorkspace boot memory browserX, Y, ZXlabel X axis nameXOR or non logicYesinput intelligent input instructionYlabel Y axis nameZeros all zero arrayZlabel Z axis nameZoom zoom in and zoom out of zoom graphicsZtrans symbolic computation, Z transform。
分享我的分享当前分享返回分享首页»分享matlab命令,应该很全了!来源:李家叶的日志matlab命令一、常用对象操作:除了一般windows窗口的常用功能键外。
1、!dir 可以查看当前工作目录的文件。
!dir& 可以在dos状态下查看。
2、who 可以查看当前工作空间变量名,whos 可以查看变量名细节。
3、功能键:功能键快捷键说明方向上键Ctrl+P 返回前一行输入方向下键Ctrl+N 返回下一行输入方向左键Ctrl+B 光标向后移一个字符方向右键Ctrl+F 光标向前移一个字符Ctrl+方向右键Ctrl+R 光标向右移一个字符Ctrl+方向左键Ctrl+L 光标向左移一个字符home Ctrl+A 光标移到行首End Ctrl+E 光标移到行尾Esc Ctrl+U 清除一行Del Ctrl+D 清除光标所在的字符Backspace Ctrl+H 删除光标前一个字符Ctrl+K 删除到行尾Ctrl+C 中断正在执行的命令4、clc可以命令窗口显示的内容,但并不清除工作空间。
二、函数及运算1、运算符:+:加,-:减,*:乘,/:除,\:左除^:幂,‘:复数的共轭转置,():制定运算顺序。
2、常用函数表:sin( ) 正弦(变量为弧度)Cot( ) 余切(变量为弧度)sind( ) 正弦(变量为度数)Cotd( ) 余切(变量为度数)asin( ) 反正弦(返回弧度)acot( ) 反余切(返回弧度)Asind( ) 反正弦(返回度数)acotd( ) 反余切(返回度数)cos( ) 余弦(变量为弧度)exp( ) 指数cosd( ) 余弦(变量为度数)log( ) 对数acos( ) 余正弦(返回弧度)log10( ) 以10为底对数acosd( ) 余正弦(返回度数)sqrt( ) 开方tan( ) 正切(变量为弧度)realsqrt( ) 返回非负根tand( ) 正切(变量为度数)abs( ) 取绝对值atan( ) 反正切(返回弧度)angle( ) 返回复数的相位角atand( ) 反正切(返回度数)mod(x,y) 返回x/y的余数sum( ) 向量元素求和3、其余函数可以用help elfun和help specfun命令获得。
matlab基本命令
1. clear:清除工作空间中的变量
2. clc:清除命令窗口中的所有输出
3. close:关闭图形窗口
4. format:设置命令窗口输出格式
5. save:保存变量到文件
6. load:从文件中加载变量
7. help:查看函数的帮助文档
8. who:列出工作空间中的变量
9. whos:列出工作空间中所有变量的详细信息
10. input:从命令窗口输入变量值
11. disp:显示字符串或变量值
12. fprintf:格式化输出文本
13. plot:绘制二维图形
14. subplot:在同一个图形窗口中绘制多个子图
15. figure:创建一个新的图形窗口
16. axis:设置坐标轴范围和刻度
17. xlabel、ylabel:设置坐标轴标签
18. title:设置图形标题
19. legend:添加图例
20. hold:设置图形是否保持当前状态,以便在之后添加新数据
21. grid:显示坐标轴网格线
22. loglog、semilogx、semilogy:设置坐标轴对数刻度
23. size:返回数组的大小
24. length:返回数组的长度
25. max:返回数组中的最大值
26. min:返回数组中的最小值
27. sum:返回数组中所有元素的和
28. mean:返回数组中所有元素的平均值
29. diff:返回数组元素之间的差分
30. sort:返回数组排序后的结果。
matlab的常用指令及其含义1、清除命令窗口clc2、清除变量clear3、清除figureclf4、生成一个图层figure()figure(1)figure('name','实例')gwin=figure('MenuBar','none','NumberTitle','off','Name','菜单创建演示','Position',[(rect(3)-N)/2,(rect(4)-N)/2,N,N],'Resize','off','Color','red');5、打印disp(a)fprintf('the value of pi is%6.2f\n',pi)6、字符串和数字转换str2num(123)num2str('123')7、取整函数floor(2.3)==2 %为向下取整ceil(2.3)==3 %为向上取整round(2.3)==2 %为取最接近的整数fix(-3.5)==-3 %为向0取整8、复数运算temp = complex(1,2) %构造函数,==2+5ireal(temp) == 1 %返回实部imag(temp)==5 %返回虚部abs(temp)==5.3852 %返回模conj(temp)==2-5i %返回共轭复数9、快速生成矩阵A=zeros(5) %5行5列的0矩阵B=ones(5) %5行5列的1矩阵A=zeros(m,n) %m行n列0矩阵B=ones(m,n) %m行n列1矩阵A=eye(5) %5行5列的单位矩阵B=rand(3,5) %3行5列的0~1之间的随机矩阵A=magic(5) %5行5列的魔方矩阵,注意这里行和列必须相同10、生成随机矩阵rand(1,5) %生成一个1行5列的矩阵,即行向量11、求最大值max12、数据库结果转矩阵data_mat = cell2mat(data_cell);data_cell是数据库返回的结果,data_mat是矩阵13、求转置矩阵a=[1; 2; 3];b=a.'; %点+单引号b->{1 2 3}14、打印时间disp(datestr(datetime('now')));15、将矩阵转化为列向量,即列矩阵B=A(:); %A是矩阵16、读取矩阵取前N行或N列A(1:2,:) %读取矩阵A的1~2行A(:,1:3) %读取矩阵A的1~3列17、矩阵运算(加、减、乘、除、点乘、点除等)(1)A+B; 表示矩阵A和矩阵B相加(各个元素对应相加);(2)A-B; 表示矩阵A和矩阵B相减(各个元素对应相减);(3)A*B; 表示矩阵A和矩阵B相乘;(4)A.*B; 表示矩阵A和矩阵B对应元素相乘(点乘);(5)A/B; 表示矩阵A与矩阵B相除法;(6)A./B; 表示矩阵A和矩阵B对应元素相除(点除);(7)A^B; 表示矩阵A的B次幂;(8)A.^B; 表示矩阵A的每个元素的B次幂18、获取数组的行数和列数[rows,colums]=size(cell_data); %cell_data是2行3列的数组,rows==2 colums==319、获取数组的指定行和指定列first = cell_data(1,:); %第一行所有列first = cell_data(:,1); %第一列所有行。
Matlab常⽤命令和数学符号表⽰转⾃:知乎:百度问答:1.最常⽤命令clc:清空命令⾏窗⼝close:关闭图形窗⼝(close all:关闭所有打开的图形窗⼝)clear:清除⼯作区变量clf:清空当前图形窗⼝figure:创建图窗窗⼝2.常⽤数学函数sin():正弦函数cos():余弦函数tan():正切函数cot():余切函数asin():反正弦函数acos():反余弦函数atan():反正切函数acot():反余切函数exp():以e为底的指数函数log():以e为底的对数函数log10():以10为底的对数函数sqrt():平⽅根函数abs():绝对值函数sum():求和函数mean():求平均值函数mod(a,m):求a/m的余数3.取整命令round():四舍五⼊为最近的整数或⼩数floor():朝负⽆穷⼤四舍五⼊ceil():朝正⽆穷⼤四舍五⼊fix():朝零四舍五⼊4.创建特殊矩阵ones():创建全部为1的数组或矩阵zeros():创建全部为0的数组或矩阵eye():创建单位矩阵diag():创建对⾓矩阵或获取对⾓元素magic():创建幻⽅矩阵rand():⽣成0到1之间均匀分布随机数randn():⽣成正态分布随机数randperm(n):创建1到n之间随机排列向量5.矩阵运算length():最⼤数组维度的长度size():返回数组的⼤⼩,如⼆维矩阵就返回⾏数和列数reshape():重构数组inv():矩阵求逆det():矩阵⾏列式eig():矩阵特征值和特征向量trace():矩阵对⾓元素之和6.多项式poly():返回具有指定根的多项式系数polyval(p,x):计算以p为系数的多项式在点x处的值polyfit():多项式曲线拟合roots(p):求多项式p=0的根interp1():⼀维插值interp2():⼆维插值interp3():三维插值7.画图plot():绘制⼆维图形plotyy():绘制具有两个y轴的图形(yyaxis:创建具有两个y轴的图)plot3():三维线图mesh():三维⽹格图surf():三维曲⾯图contour():矩阵的等⾼线图contour3():三维等⾼线图fill():填充的⼆维多边形bar():条形图subplot():在同⼀个图形窗⼝,创建多个图形area():填充取⼆维绘图pie():⼆维饼图pie3():三维饼图stairs():阶梯图stem():枝⼲图(绘制离散数据)compass():绘制从原点出发的箭头8.⼀些特殊的数学符号表⽰这些特殊字符有效区域主要集中在:Axes中标识整个坐标系的Title, X, Y, Z轴的Label, 以及Annotation中TextBox, Legend上标, 下标上标格式: 字符或数字^{上标}, 这样出来的就是: 字符或数字上标 ,下标格式: 字符或数字_{下标}, 出来的效果就像: 字符或数字下标 ,⽂档中的Text Properties:下标⽤ _(下划线),上标⽤^ (尖号)斜体 \it ⿊体 \bf;⽐如在坐标轴的[0.5 0.5]位置上要显⽰δ字符,那么可以直接输⼊text(0.5,0.5,'\delta')如果需要显⽰⼤写希腊字符的话,那直接将⾸字母改为⼤写就可以了;在matlab中输⼊输⼊特殊符号需要反斜杠的配合。
1命令行中输入help+工具箱名或函数名,可以显示对应的功能信息。
2 matlab中同样支持复数变量,表示方法为a=m+ni(j)。
当n是表达式时,n与i(j)之间必须要加乘号 b=1+a*i。
另外也可以用complex(x,y)来产生复数。
在循环程序段中一般不把i和j作为变量名称,以免生成数据时发生误解。
3>> i=5;>> a=5+2ia =5.0000 + 2.0000i>> a=5+2*ia =154 first:increment:last表示创建一个从first开始,到last结束,数据元素的增量为increment的等差数组。
冒号表示直接定义数据元素之间的增量,而不是数据元素个数。
若增量为1,上面创建数组的方式可简写为: first:last。
5 linspace通过直接定义数据元素个数,而不是数据元素之间的增量来创建数组。
此函数的调用格式如下:linspace(firstvalue,lastvalue,number)6,与linspace一样,logspace函数也通过直接定义数据元素个数,而不是数据元素之间的增量来创建数组。
logspace函数的调用格式为:logspace(firstvalue,lastvalue,number)此函数表示创建一个从10的firstvalue次幂开始,到10的lastvalue 次幂结束,包含有number个数据元素的等比数组7,数组与标量的四则运算是指数组中的每个元素与标量进行加、减、乘、除运算。
数组的指数运算为exp,以2为底的指数运算为pow2;数组自然对数运算为log,常用对数运算为log10,以2为底的对数运算为log2,开方运算sqrt。
数组与数组之间进行运算时,每个数组必须具有相同的维数,且必须用点乘或点除。
这些运算都是数组中每个元素进行相对应的运算.a=exp([1 2])a =2.7183 7.3891查询x数组的第n个元素,x(n);查询x数组的第2到4个元素,x(2:4);查询x数组的第4到最后1个元素,x(4:end);查询x数组的第3、2、1个元素,x(3:-1:1);查询x数组的小于n元素,x(find(x<n));查询x数组的第4、2、5个元素,x([4 2 5]);将x数组的第n个元素赋值为A,x(n)=A;查询数组A的第2行,第3列的元素,A(2,3);查询数组A的第3行所有的元素,A(3,:);查询数组A的第2列转置后所有的元素,(A(:,2))’。