MATLAB命令

MATLAB数值计算计算和数据可视化是一个交互式程序。您可以输入它的MATLAB提示符“>>”命令窗口中键入命令。

在本节中,我们将提供常用一般MATLAB命令的列表。

管理会话的命令

MATLAB提供会话管理的各种命令。下表提供了所有这样的命令:

命令目的/作用
clc清除命令窗口。
clear从内存中删除变量。
exist检查存在的文件或变量。
global声明变量为全局。
help搜索帮助主题。
lookfor搜索帮助关键字条目。
quit停止MATLAB。
who列出当前变量。
whos列出当前变量(长显示)。

使用系统命令

MATLAB提供各种有用的命令与系统工作,在工作区中当前的工作,如保存为一个文件,并加载文件。

它还提供了其他系统相关的活动,如各种命令,显示日期,列出目录中的文件,显示当前目录等。

下表显示了一些常用的系统相关的命令:

命令目的/作用
cd改变当前目录。
date显示当前日期。
delete删除一个文件。
diary日记文件记录开/关切换。
dir列出当前目录中的所有文件。
load负载工作区从一个文件中的变量。
path显示搜索路径。
pwd显示当前目录。
save保存在一个文件中的工作区变量。
type显示一个文件的​​内容。
what列出所有MATLAB文件在当前目录中。
wklread读取.wk1电子表格文件。 

输入和输出命令

MATLAB提供了以下输入和输出相关的命令:

命令作用/目的
disp显示一个数组或字符串的内容。
fscanf阅读从文件格式的数据。
format控制屏幕显示的格式。
fprintf执行格式化写入到屏幕或文件。
input显示提示并等待输入。
;禁止显示网版印刷

fscanf和fprintf命令的行为像C scanf和printf函数。他们支持格式如下代码:

格式代码目的/作用
%sFormat as a string.
%dFormat as an integer.
%fFormat as a floating yiibai value.
%eFormat as a floating yiibai value in scientific notation.
%gFormat in the most compact form: %f or %e.
Insert a new line in the output string.
Insert a tab in the output string.

用于数字显示格式的函数有以下几种形式:

Format函数最多可显示
format shortFour decimal digits (default).
format long16 decimal digits.
format short eFive digits plus exponent.
format long e16 digits plus exponents.
format bankTwo decimal digits.
format +Positive, negative, or zero.
format ratRational approximation.
format compactSuppresses some line feeds.
format looseResets to less compact display mode.

向量,矩阵和阵列命令

下表列出了各种命令用于工作数组,矩阵和向量:

命令作用/目的
catConcatenates arrays.
findFinds indices of nonzero elements.
lengthComputes number of elements.
linspaceCreates regularly spaced vector.
logspaceCreates logarithmically spaced vector.
maxReturns largest element.
minReturns smallest element.
prodProduct of each column.
reshapeChanges size.
sizeComputes array size.
sortSorts each column.
sumSums each column.
eyeCreates an identity matrix.
onesCreates an array of ones.
zerosCreates an array of zeros.
crossComputes matrix cross products.
dotComputes matrix dot products.
detComputes determinant of an array.
invComputes inverse of a matrix.
pinvComputes pseudoinverse of a matrix.
rankComputes rank of a matrix.
rrefComputes reduced row echelon form.
cellCreates cell array.
celldispDisplays cell array.
cellplotDisplays graphical representation of cell array.
num2cellConverts numeric array to cell array.
dealMatches input and output lists.
iscellIdentifies cell array.

绘图命令

MATLAB提供了大量的命令,绘制图表。下表列出了一些常用的命令绘制:

命令作用/目的
axisSets axis limits.
fplotIntelligent plotting of functions.
gridDisplays gridlines.
plotGenerates xy plot.
printPrints plot or saves plot to a file.
titlePuts text at top of plot.
xlabelAdds text label to x-axis.
ylabelAdds text label to y-axis.
axesCreates axes objects.
closeCloses the current plot.
close allCloses all plots.
figureOpens a new figure window.
gtextEnables label placement by mouse.
holdFreezes current plot.
legendLegend placement by mouse.
refreshRedraws current figure window.
setSpecifies properties of objects such as axes.
subplotCreates plots in subwindows.
textPlaces string in figure.
barCreates bar chart.
loglogCreates log-log plot.
polarCreates polar plot.
semilogxCreates semilog plot. (logarithmic abscissa).
semilogyCreates semilog plot. (logarithmic ordinate).
stairsCreates stairs plot.
stemCreates stem plot.
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值