MATLAB常用指令记录


help  + 'command name' % 查询指令用法 
Ctrl + Break % 强制终止程序运行
Shift + Enter % command window下换行不运行指令

M'; % 复数的共轭,矩阵的转置
inv() % 矩阵的逆
det() % 矩阵的行列式值
rank() % 求出矩阵的秩
n = norm(X,p) % 求矩阵的p范数

clear all;clc; % 清除工作空间,清空command window记录
set(0,'defaultfigurecolor','w'); % 设置figure背景为白色

X = zeros(n) % Create a n-by-n array of 0
X = zeros(sz1,...,szN) % Create a sz1-...-szN array of 0
X = ones(sz1,...,szN); % Create a sz1-...-szN array of 1
I = eye(n); % Create a n-by-n identity identity matrix

r = rand(sz1,...,szN); % 产生一个均匀分布的伪随机数矩阵
r = randn(sz1,...,szN); % 产生一个标准正态分布的伪随机数矩阵
r = randi(sz1,...,szN); % 产生一个均匀分布的伪随机整数矩阵

B = reshape(A,[m n]); % returns the m-by-n matrix B according A
length() % 返回矩阵最长维的的长度
size() % 返回每一维的长度
blkdiag(A, B) % 以A,和B为块创建块对角矩阵

abs(); % 取绝对值/模
angle(); % 取角度
log2(n); % log以2为底取对数
exp(); % 指数
sqrt(); % 开方
sind(theta); % theta为角度
sin(theta); % theta为弧度


% 计时器,结束时显示过程时间
tic
...
toc

% 进度条
hWait = waitbar(0,'Please wait...');
steps = 1000;
for step = 1:steps
    % computations take place here
    waitbar(step / steps);
end
close(hWait); 

figure; % 创建新的figure
set(0,'DefaultFigureProperty',PropertyValue...); % 设置figure默认参数属性

plot(X,Y); % 绘制曲线图
===============================================================
        颜色           线型
---------------------------------------------------------------
        y   黄色       .    圆点线         v      向下箭头 
        g   绿色       -.   组合           >      向右箭头 
        b   蓝色       +    点为加号形     <      向左箭头 
        m   红紫色     o    空心圆形       p      五角星形 
        c   蓝紫色     *    星号           h      六角星形 
        w   白色       .    实心小点       -      实线
        r   红色       x    叉号形状       ^      向上箭头 
        k   黑色       s    方形                     
        d   菱形       --   虚线                
===============================================================

subplot(m,n,p); % 平铺figure为m行n列,指定当前figure为第p个
polar(theta,rho) % 绘制极坐标图,theta,rho分别是向量

set(gca, 'Fontname', '微软雅黑');
xlabel('---', 'Fontname', '微软雅黑'); % 设置x轴标号样式
title('---', 'Fontname', '微软雅黑'); % 设置标题样式
axis([xMin xMax yMin yMax]); % 控制坐标显示范围

grid on; % 开启网格

猜你喜欢

转载自www.cnblogs.com/Ran-Chen/p/9235943.html