[初学笔记] 常用命令

MATLAB命令大全
本文汇总了MATLAB中常用的各类命令,包括管理会话、使用系统命令、输入输出操作、向量矩阵操作及绘图等。这些命令对于进行科学计算、数据分析及可视化非常有用。

管理会话的命令

命令

目的/作用

clc

清除命令窗口。

clear

从内存中删除变量。

exist

检查存在的文件或变量。

global

声明变量为全局。

help

搜索帮助主题。

lookfor

搜索帮助关键字条目。

quit

停止MATLAB。

who

列出当前变量。

whos

列出当前变量(长显示)。

 

 

使用系统命令

命令

目的/作用

cd

改变当前目录。

date

显示当前日期。

delete

删除一个文件。

diary

日记文件记录开/关切换。

dir

列出当前目录中的所有文件。

load

负载工作区从一个文件中的变量。

path

显示搜索路径。

pwd

显示当前目录。

save

保存在一个文件中的工作区变量。

type

显示一个文件的​​内容。

what

列出所有MATLAB文件在当前目录中。

wklread

读取.wk1电子表格文件。 

 

 

输入和输出命令

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

命令

作用/目的

disp

显示一个数组或字符串的内容。

fscanf

阅读从文件格式的数据。

format

控制屏幕显示的格式。

fprintf

执行格式化写入到屏幕或文件。

input

显示提示并等待输入。

;

禁止显示网版印刷

 

 

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

格式代码

目的/作用

%s

Format as a string.

%d

Format as an integer.

%f

Format as a floating yiibai value.

%e

Format as a floating yiibai value in scientific notation.

%g

Format 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 short

Four decimal digits (default).

format long

16 decimal digits.

format short e

Five digits plus exponent.

format long e

16 digits plus exponents.

format bank

Two decimal digits.

format +

Positive, negative, or zero.

format rat

Rational approximation.

format compact

Suppresses some line feeds.

format loose

Resets to less compact display mode.

 

 

向量,矩阵和阵列命令

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

命令

作用/目的

cat

Concatenates arrays.

find

Finds indices of nonzero elements.

length

Computes number of elements.

linspace

Creates regularly spaced vector.

logspace

Creates logarithmically spaced vector.

max

Returns largest element.

min

Returns smallest element.

prod

Product of each column.

reshape

Changes size.

size

Computes array size.

sort

Sorts each column.

sum

Sums each column.

eye

Creates an identity matrix.

ones

Creates an array of ones.

zeros

Creates an array of zeros.

cross

Computes matrix cross products.

dot

Computes matrix dot products.

det

Computes determinant of an array.

inv

Computes inverse of a matrix.

pinv

Computes pseudoinverse of a matrix.

rank

Computes rank of a matrix.

rref

Computes reduced row echelon form.

cell

Creates cell array.

celldisp

Displays cell array.

cellplot

Displays graphical representation of cell array.

num2cell

Converts numeric array to cell array.

deal

Matches input and output lists.

iscell

Identifies cell array.

 

 

绘图命令

命令

作用/目的

axis

Sets axis limits.

fplot

Intelligent plotting of functions.

grid

Displays gridlines.

plot

Generates xy plot.

print

Prints plot or saves plot to a file.

title

Puts text at top of plot.

xlabel

Adds text label to x-axis.

ylabel

Adds text label to y-axis.

axes

Creates axes objects.

close

Closes the current plot.

close all

Closes all plots.

figure

Opens a new figure window.

gtext

Enables label placement by mouse.

hold

Freezes current plot.

legend

Legend placement by mouse.

refresh

Redraws current figure window.

set

Specifies properties of objects such as axes.

subplot

Creates plots in subwindows.

text

Places string in figure.

bar

Creates bar chart.

loglog

Creates log-log plot.

polar

Creates polar plot.

semilogx

Creates semilog plot. (logarithmic abscissa).

semilogy

Creates semilog plot. (logarithmic ordinate).

stairs

Creates stairs plot.

stem

Creates stem plot.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值