Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Rik
Rik il 1 Giu 2018
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);

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by