无法在matlab中使用置换nd数组

Unable to use permute nd array in matlab

X 是 4d 数组,大小为 - 50000x3x32x32。我想将 4d 数组转置为 50000x32x32x3。

Y = permute(X, [1 4 2 3]);

但是,Y的维度还是50000x32x3x32。但它应该是 50000x32x32x3。有人可以帮我看看这里有什么问题吗?提前致谢。

这里是 online documentation 的定义:

B = permute(A,order) rearranges the dimensions of A so that they are in the order specified by the vector order.

我们可以使用 size 来获取数组的维度:

S = size(X)

S =

[50000 3 32 32]

我们要重新排序维度向量,使其变为 [50000 32 32 3]。那么我们应该设置顺序为[1 3 4 2].

order = [1 3 4 2];
S_result = S(order)

S_result =
[50000 32 32 3]