【发布时间】:2015-06-27 16:38:22
【问题描述】:
我有一个 3x3x2000 的旋转矩阵数组,需要将其转换为 2000x9 的数组。
我认为我必须使用 permute() 和 reshape() 的组合,但我没有得到正确的输出顺序。
这是我需要的:
First row of 3x3 array needs to be columns 1:3 in the output
Second row of 3x3 array needs to be columns 4:6 in the output
Third row of 3x3 array needs to be columns 7:9 in the output
我已经在以下代码中尝试了所有可能的数字 1 2 3 组合:
out1 = permute(input, [2 3 1]);
out2 = reshape(out1, [2000 9]);
但我总是以错误的顺序结束。给 Matlab 新手的任何提示?
【问题讨论】:
-
给出一个输入和期望输出的小例子,它将帮助潜在的志愿者知道他们是否做对了。提示:您可能必须在转换中包含一些转置 (
.') 操作,并且不要忘记 Matlab 是column major(例如 线性索引按列而不是按行工作)。