フィルターのクリア

How can i add a 2D matrix of zeros on top of a 3D matrix of logicals

2 ビュー (過去 30 日間)
David van Nederpelt
David van Nederpelt 2018 年 6 月 1 日
Hi,
I've subtracted the bottom z values of a 3D matrix (ffilter) and now i want to add a 2D matrix in the z direction on top, to create a new matrix (ffilter2).
if true
ffilter2=ffilter2(:,:,(1:617));
[N,v,b]=size(ffilter2)
c=zeros(N,v,1);
ffilter2=ffilter2(:,:,(c:618));
end
I have a 2D matrix of zeros (size = x_of3D_matrix;y_of3D_matrix,1). And I want to "add" this to the 3D matrix so this will result in an 3D matrix with an extra layer (of zeros) in the z direction (on top). I probably didn't formulate this the proper way. But I hope somebody understands what I'm asking. All the help is really appreciated!
Thank you.

採用された回答

Rik
Rik 2018 年 6 月 1 日
You can use the cat function:
ffilter2=ffilter2(:,:,(1:617));
[N,v,b]=size(ffilter2)
c=zeros(N,v,1,'like',ffilter2);%or c=false(N,v,1);
ffilter2=cat(3,ffilter2,c);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by