Reshaping/vectorizing a n-d matrix to a vector along each dimension

4 ビュー (過去 30 日間)
kowshik Thopalli
kowshik Thopalli 2018 年 4 月 5 日
回答済み: James Tursa 2018 年 4 月 5 日
Lets say I have a matrix given by
a=randn(4,4,5);
How do I get a 80*1 vector along each dimension. That is the new vector vec B should look like the following
B=[a(1,1,1),a(1,1,2),..a(1,1,5),a(1,2,1),..,a(1,2,5),...a(4,4,5)]'
Both the below commands will not give this
B=a(:);
B=reshape(a,[80,1]);

採用された回答

James Tursa
James Tursa 2018 年 4 月 5 日
result = reshape(permute(a,[3 2 1]),[],1);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by