multidimensional array to column vector with different dimensional order?

Say I have two arrays:
if true
% code
count = 1;
for m = 1:3
for n = 1:3
for k = 1:3
A(count) = count;
count = count + 1;
end
end
end
end
if true
% code
count = 1;
for m = 1:3
for n = 1:3
for k = 1:3
B(m,n,k) = count;
count = count + 1;
end
end
end
end
Now, if I reshape B into a column vector (using B = B(:)), the order of the elements is different from A although the elements are the same.
Is there a way I can reshape B so that it is equal to A?
Thanks!

 採用された回答

Mischa Kim
Mischa Kim 2014 年 3 月 18 日
Sriram, use
reshape(permute(B,[3 2 1]),1,27)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Types についてさらに検索

質問済み:

2014 年 3 月 18 日

回答済み:

2014 年 3 月 18 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by