Reshaping a 3 dimensional array to 2 dimensions

谁说胖子不能爱 提交于 2019-12-11 00:47:43

问题


I have a 3-dimensional matrix of dimensions: 427x470x48

I want to reshape this into a 2-dimensional matrix of dimensions: 48x200690

This would mean that old(1, 1, :) would correspond to new(:, 1)

Additionally, old(1,2,:) would correspond to new(:,2) and so on and so forth.

Thank You


回答1:


Do:

new = reshape(permute(old, [3 2 1]), 48, []);

Also you can roughly check that they are equal by:

numel(intersect(old(1,1,:),new(:,1))) == 48;


来源:https://stackoverflow.com/questions/18004989/reshaping-a-3-dimensional-array-to-2-dimensions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!