3d matrix to 2d matrix
显示 更早的评论
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
回答(1 个)
Star Strider
2018-5-3
I would use the reshape function:
B = reshape(A, [], 1);
You may have to experiment with it to get the result you want.
类别
在 帮助中心 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!