필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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 CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by