【问题标题】:extracting 2D array from 4D array in matlab [duplicate]从matlab中的4D数组中提取2D数组[重复]
【发布时间】:2016-05-15 12:33:15
【问题描述】:

我在 matlab 中有一个类似这样的 4D 数组,

test(:,:,1,1) =

     0


test(:,:,2,1) =

     0


test(:,:,3,1) =

     0


test(:,:,4,1) =

     0


test(:,:,5,1) =

     0


test(:,:,1,2) =

     0


test(:,:,2,2) =

     0


test(:,:,3,2) =

     0


test(:,:,4,2) =

     0


test(:,:,5,2) =

     0


test(:,:,1,3) =

     0


test(:,:,2,3) =

     0


test(:,:,3,3) =

     0


test(:,:,4,3) =

     0


test(:,:,5,3) =

     0


test(:,:,1,4) =

     0


test(:,:,2,4) =

     0


test(:,:,3,4) =

     0


test(:,:,4,4) =

     0


test(:,:,5,4) =

     0


test(:,:,1,5) =

     0


test(:,:,2,5) =

     0


test(:,:,3,5) =

     0


test(:,:,4,5) =

     0


test(:,:,5,5) =

     0

K>> test

test(:,:,1,1) =

     0


test(:,:,2,1) =

     0


test(:,:,3,1) =

     0


test(:,:,4,1) =

     0


test(:,:,5,1) =

     0


test(:,:,1,2) =

     0


test(:,:,2,2) =

     0


test(:,:,3,2) =

     0


test(:,:,4,2) =

     0


test(:,:,5,2) =

     0


test(:,:,1,3) =

     0


test(:,:,2,3) =

     0


test(:,:,3,3) =

     0


test(:,:,4,3) =

     0


test(:,:,5,3) =

     0


test(:,:,1,4) =

     0


test(:,:,2,4) =

     0


test(:,:,3,4) =

     0


test(:,:,4,4) =

     0


test(:,:,5,4) =

     0


test(:,:,1,5) =

     0


test(:,:,2,5) =

     0


test(:,:,3,5) =

     0


test(:,:,4,5) =

     0


test(:,:,5,5) =

     0

现在我想得到一个数组,像这样

ans =

     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0
     0     0     0     0

有没有一种简单的方法来转换尺寸。 我对 Matlab 中的多维数组非常陌生。 如果有人知道任何解决方案,请告诉我。

【问题讨论】:

  • @Daniel 好的。向所有人道歉。我会删除我的 cmets。

标签: arrays matlab


【解决方案1】:

使用squeeze函数,当你输入一个大小为[1 1 5 4]的矩阵时,它会返回一个大小为[5 4]的矩阵

【讨论】:

  • 感谢您的回答。如果您碰巧在 reshape 命令的帮助下知道相同的修改,请告诉我,那将是另一种帮助。问候
  • 如果您查看标记为重复的问题(本页顶部),您可以在其中一个答案中找到示例。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-08
  • 1970-01-01
  • 1970-01-01
  • 2018-05-12
  • 2016-08-12
  • 1970-01-01
相关资源
最近更新 更多