フィルターのクリア

What does the matlab code in steps 2 and 3 mean?

7 ビュー (過去 30 日間)
Pooja
Pooja 2012 年 7 月 29 日
1.Hphi=Heaviside(phi,epsilon);
2.M(:,:,1)=Hphi;
3.M(:,:,2)=1-Hphi;
4.N_class=size(M,3);

回答 (1 件)

Wayne King
Wayne King 2012 年 7 月 29 日
編集済み: Wayne King 2012 年 7 月 29 日
M is a 3-D matrix.
M(:,:,1) = Hphi;
Means set the first "page" of the 3rd dimension equal to the output of Heaviside with inputs phi and epsilon, which here is Hphi.
M(:,:,2) = 1-Hphi;
Means set the second "page" of the 3rd dimension equal to 1-Hphi.
In general, M(:,:,index) is the way of assigning all rows and all columns of the index-th page of a 3D matrix a given value.
For example:
M = zeros(2,2,2); % M is 2x2x2
M(:,:,1) = 1;
M(:,:,2) = 2;
Now M(:,:,1) is a 2x2 matrix of ones and M(:,:,2) is a 2x2 matrix of 2s.
N_class = size(M,3);
Is just returning the size of M in the 3rd dimension
M = ones(2,2,4);
size(M,3)
Are you trying to read the Matlab documentation?

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by