Effacer les filtres
Effacer les filtres

how can i add a 3dim matrix to another one as every odd cell

2 vues (au cours des 30 derniers jours)
Nahid Atashi
Nahid Atashi le 19 Nov 2018
Commenté : Nahid Atashi le 19 Nov 2018
Hi everybody,
I have two matrices with 3 dim A(4*20*55512) and B(4*20*5512). the third dimention is time. I want to put matrix B below the matrix A in third dim but
as the first cell should be the first value of matrix A and the second cell should be the first value of matrix B. i can do it for a 2 dim matrix by reshape
but not for 3dim. can eveyone help me please? thanks
time in matrix A is (0,6,12,18) and in matrix B (3,9,15,21). so i want to have a matrix with C(4*20*11024) and time would be (0,3,6,9,12,15,18,21).

Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 19 Nov 2018
s = size(B);
out = zeros(c .* [1,1,2]);
out(:,:,1:2:s(3)*2) = A(:,:,1:s(3));
out(:,:,2:2:s(3)*2) = B;
  1 commentaire
Nahid Atashi
Nahid Atashi le 19 Nov 2018
thank you so much Andrei, the answer was perfect

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by