基本命令
close all //关闭所有figure 命令打开的窗口,在命令窗口输入
clear all //清除之前运行程序所存下的所有变量
size(mat)
a = [1 2 3 ; 4 5 6 ]
size(a) = [2 3] //size(mat) = [rownum, colnum]
delete certain col in mtrix
A = [1 2 3 ; 4 5 6 ; 7 8 9];
A(:, 3) = [];
reshape array
z = reshape(preds(3,:,:),14,177); //it will reduce demension of preds to 14X177
A = [1 2; 3 4]; permute(A,[2 1]) %%convert div 2 with div 1.
ans =
1 3
2 4
cat %%merge matrix A ,B to a new matrix, extend div possibly
heatmap = cat(4,heatmap,hm)
矩阵连接
[s1 s2] %%右侧连接
[s1; s2] %%下侧连接
convert num to string
num2str
convert a cell struct to mat type
cell2mat
waitforbuttonpress: you can put it into for loop
subs = regexp(string, 'c', 'split'); %%将string以'c'为分隔符分割为若干子串并保存至subs中
%%注意:subs是一个cell型数据,其每个元素是cell型的,只能display,不能直接进行字符串操作(如截取或者连接),这时需要字符转换:如,s1=char(subs(1))
画图
hist(x); %%show the 2-D array x' hist
mesh(Z) %%plot 3D figure, where Z is f(m ,n).
I = imgaussfilt(I, 'FilterSize', 11); %%I is image, 11 is size of filter size
连接图
plot(y) //默认x坐标为正整数
plot(x, y)
hold on //表示下次画图基于本图
散点图
scatter(x, y) //以x,y为横纵坐标画散点
scatter(x, y, ‘filled’) 也可以改为 ‘rx’ //即以不同元素表示散点