Elegant way of "sending to the next row" in a matrix
8 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have a 1x36 matrix that I want to cut in bits. In my specific case I want to obtain a 6x6 matrix from this 1x36 matrix. Every 6 column of the original 1x36 matrix I want to go to a next row.
How can I do this in an elegant way?
Thanks!
0 件のコメント
採用された回答
Anthony Poulin
2015 年 9 月 10 日
I have not the same result and using a transpose I think that I get what you want.
A=1:10;
B=reshape(A, [5,2])'
So, B =
1 2 3 4 5
6 7 8 9 10
その他の回答 (1 件)
Anthony Poulin
2015 年 9 月 10 日
Hello,
Do you try to use the "reshape" function?
2 件のコメント
Hamoon
2015 年 9 月 10 日
編集済み: Hamoon
2015 年 9 月 10 日
B=reshape(A,[5,2])
means B will be a (5*2) matrix, you're doing something wrong Matt, just clear your workspace variables and try again. as Anthony said you'll get the result you want using:
A=1:10;
B=reshape(A,[5,2]);
C=B';
C is what you want, and B is a (5*2) matrix
B =
1 6
2 7
3 8
4 9
5 10
C =
1 2 3 4 5
6 7 8 9 10
参考
カテゴリ
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!