About trasfor two dimensions to three dimensions

1 view (last 30 days)
I want to ask a simple question,but I just can't solve it.
My data follow below
A=(23*25). B=(23*25)
Then I want to change A & B to C=(6*23*25)
The c(1,:,:),c(2,:,:)and c(3,:,:)are A
The c(4,:,:),c(5,:,:)and c(6,:,:)are B
How can I use loop or something to make it happen?
Thanks

Accepted Answer

Marc Jakobi
Marc Jakobi on 9 Oct 2016
I assume 23*25 are the dimensions of the matrices?
You could do something like this:
c = zeros(6, 23, 25);
c(1:3,:,:) = permute(repmat(A,1,1,3),[3,1,2]);
c(4:6,:,:) = permute(repmat(B,1,1,3),[3,1,2]);

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!