Reshape by rows instead of columns
55 ビュー (過去 30 日間)
古いコメントを表示
I have a 1260 by 1 column vector (myVector) that I want to reshape to a 35*36 matrix. However, I can't figure out how to reshape it the particular way that I want:
reshape(myVector,35,36) takes each successive chunk of 35 elements from myVector and makes them the 36 columns of the new matrix. But I want to take each successive chunk of 36 elements from myVector and make each chunk the 35 rows of the new matrix. How do I do this?
0 件のコメント
採用された回答
Max Alger-Meyer
2022 年 3 月 8 日
If I understand you correctly, all you need to do is transpose the reshaped result:
vector = 1:16
array1 = reshape(vector,4,4)
transpose(array1)
5 件のコメント
Bruno Luong
2022 年 8 月 29 日
@Amr Aboughazala "taking the transpose won't give the first answer"
because you take transpose on a wrong reshape.
The correct one is
x = [0,1,2,3,4,5];
reshape(x,[2,3])' % size is [2,3] not [3,2]
It does fine.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!