【问题标题】:Reshape mxn cell array to mxnxt 3D matrix in Matlab在Matlab中将mxn单元阵列重塑为mxnxt 3D矩阵
【发布时间】:2015-09-21 13:25:26
【问题描述】:

我查看了过去的答案,但我找到了一个为我的案例提供了明确答案的答案(很奇怪,因为它看起来很简单)。

我有一个 mxn 元胞数组,每个元胞数组都有一个 tx1 矩阵,我想将其重塑为一个 mxnxt 3D 矩阵。我看到了几个 permute 和 remat 的例子,但没有得到我的答案。

谢谢!

【问题讨论】:

  • 就语义而言,没有“3D 矩阵”之类的东西。从技术上讲,它将是“3 级数组”或“3D 数组”。矩阵本质上是二维的。

标签: matlab matrix 3d reshape permute


【解决方案1】:

你只需要cell2mat和一点permute

c = repmat({(1:4).'},2,3); %'// example cell array
result = permute(cell2mat(permute(c,[3 1 2])), [2 3 1])

【讨论】:

  • 完美!谢谢路易斯。
猜你喜欢
  • 2011-01-16
  • 1970-01-01
  • 1970-01-01
  • 2016-11-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多