将3维数组重塑为2维 [英] Reshaping a 3 dimensional array to 2 dimensions

查看:90
本文介绍了将3维数组重塑为2维的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个尺寸为427x470x48的3维矩阵

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

我想将其重塑为二维尺寸矩阵:48x200690

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

这意味着old(1,1,:)对应于new(:, 1)

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

此外,old(1,2,:)对应于new(:,2),依此类推.

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

谢谢

推荐答案

执行:

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;

这篇关于将3维数组重塑为2维的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆