How to rearrange 2x5 matrix while keeping the size the same?
2 ビュー (過去 30 日間)
古いコメントを表示
Hi,
How do I tranpose such that
x = [1, 5, 9, 4, 8; 3, 7, 2, 6, 10] to
x =[1, 3, 5, 7, 9 ; 2, 4, 6, 8, 10]
while keeping the 2x5 matrix? This matrix was returned from a function reading a file consisting of a row-oriented data.
thank you.
0 件のコメント
採用された回答
その他の回答 (2 件)
Steven Lord
2023 年 4 月 28 日
x = [1, 5, 9, 4, 8; 3, 7, 2, 6, 10]
y = reshape(x(:), flip(size(x))).'
For comparison:
expected =[1, 3, 5, 7, 9 ; 2, 4, 6, 8, 10]
Kevin Holly
2023 年 4 月 28 日
x = [1, 5, 9, 4, 8; 3, 7, 2, 6, 10]
x2 = reshape(sort(reshape(x,1,[])),size(x,1),size(x,2))
参考
カテゴリ
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!