matlab基本指令

本文介绍了MATLAB中的基本命令使用方法,包括变量管理、矩阵操作、数组重塑及各类绘图指令等。读者可以了解到如何关闭窗口、清除变量、进行矩阵运算,并掌握绘制直方图、三维图像及散点图的技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

基本命令

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’     //即以不同元素表示散点 

转载于:https://www.cnblogs.com/fariver/p/6500819.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值