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

2 次查看(过去 30 天)
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).

采纳的回答

Andrei Bobrov
Andrei Bobrov 2018-11-19
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;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by