简体   繁体   English

在Matlab中将mxn单元阵列重塑为mxnxt 3D矩阵

[英]Reshape mxn cell array to mxnxt 3D matrix in Matlab

I looked through past answers but I could find one that gave me a definitive answer for my case (weird as it seems simple). 我浏览了过去的答案,但找到了一个可以为我的案例提供明确答案的答案(看起来很简单,很奇怪)。

I have a mxn cell array with each having a tx1 matrix and I would like to reshape this to a mxnxt 3D matrix. 我有一个mxn单元阵列,每个单元都有一个tx1矩阵,我想将其重塑为一个mxnxt 3D矩阵。 I saw a few example with permute and remat but did not get my answer there. 我看到了一些关于置换和remat的示例,但没有得到我的答案。

Thanks! 谢谢!

You just need cell2mat with a little of permute : 您只需要带有一些permute cell2mat

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM