How to reshape a matrix by rows?

31 ビュー (過去 30 日間)
Abhishek Chakraborty
Abhishek Chakraborty 2021 年 9 月 27 日
回答済み: Abhishek Chakraborty 2021 年 9 月 27 日
I want to reshape a matrix A into a row vector but it has to be reshaped row wise. The matrix is:
A=[1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16;17 18 19 20;21 22 23 24;25 26 27 28];
I want a result like this:
B=[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28];
I tried the following:
B=reshape(A,[1,28]); %But it is reshaping columnwise
B=reshape(A,1,[]) %Again similar issue
How to get this 1x28 vector from the 7x4 matrix?

採用された回答

Abhishek Chakraborty
Abhishek Chakraborty 2021 年 9 月 27 日
Got it...
B=reshape(A',1,[]);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by