matlab基本指令

2022-08-19 20:57:10 字數 1722 閱讀 2700

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

Matlab的基本操作指令

最近在寫 的時候用到了matlab工具,然後就總結了下基本的操作指令,希望能幫助到大家 1 矩陣每一列的和 sum a 2 矩陣每一行的和 sum a,2 3 矩陣某一列指定的和 sum a 1 4 矩陣某一行指定的和 sum a 1,5 絕對值 abs 6 求平方 例如3 2 或者用power 3...

matlab中PLOT指令的基本用法

一 基本使用 plot後面的可以是單一矩陣,如果是m n的矩陣,則自動繪製m 行數 個曲線,座標為列號。plot後面的還可以是乙個或多個矩陣 向量 標量對。具體規則描述如下 plot x,y x用於產生橫座標,而y用於產生縱座標,產生對應點後,按照行號或列號進行相連產生折線圖 以下規則中向量不論是行...

matlab一些基本重要的指令

重點內容 執行matlab的幫助demo,在command window 輸入 demo 或在launch pad 選項卡 demos 任何時候都可以 清除command window內容 clc 清除figure window 圖形視窗 clf 清除workspace 變數內容 clear 注意 ...