3d matrix to 2d matrix
Show older comments
Hi guys I have a 3d matrix with values A(1:3, 1:3, 1:12) and I want to transform them into 2D matrix B where B(1,1)=A(1,1,1) B(2,1)=A(1,2,1) B(3,1)=A(1,3,1) B(4,1)=A(1,1,2)..... B(36,1)=A(1,3,12)
and I would like to to the same for 3 columns. I tried to do it with 'for' loop but it doesn't work. I'd be glad for any help ;)
for i=1:3
for l=1:12
for k=1:3
B(:,)=A(1,k,l);
end
end
end
Answers (1)
Star Strider
on 3 May 2018
I would use the reshape function:
B = reshape(A, [], 1);
You may have to experiment with it to get the result you want.
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!