Reshape - columnwise. any command to linewise?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
help reshape
RESHAPE Reshape array.
RESHAPE(X,M,N) returns the M-by-N matrix whose elements are taken columnwise from X.
I need some way to turn a matrix linewise instead.
採用された回答
Andrei Bobrov
2011 年 11 月 29 日
reshape(X.',M,N).'
8 件のコメント
Vasco
2011 年 11 月 29 日
tytyty. =)
Giacomo Perantoni
2019 年 2 月 21 日
The transpose operator may be expensive for a large matrix. Is there an alternative way to solve the original problem without the additional computational cost?
winkmal
2020 年 1 月 14 日
Should M and N not be switched in your command?
Amir
2020 年 2 月 18 日
M and N should be switched to return the M-by-N matrix.
The command should be reshape(X.',N,M).'
Med Aymane Ahajjam
2020 年 2 月 18 日
Life saver!!! Thank you!
sohaib bhatti
2021 年 8 月 30 日
How can the same be done if X is a 3d matrix?
Loïc Niederhauser
2022 年 4 月 26 日
Also, what if I want to reshape to a 3d matrix? Is there anyway to just work row major in matlab?
Loic -Hi btw ;-) - you could use permute for ND-array (there is also pagetranspose command more restrictive)
X=randi(9,[6 5])
X = 6×5
1 2 4 9 1
9 1 7 8 1
5 6 6 4 8
4 2 7 8 2
2 4 5 5 9
7 1 7 1 8
permute(reshape(X.',[size(X,2) 2 3]),[2 1 3])
ans =
ans(:,:,1) =
1 2 4 9 1
9 1 7 8 1
ans(:,:,2) =
5 6 6 4 8
4 2 7 8 2
ans(:,:,3) =
2 4 5 5 9
7 1 7 1 8
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Numeric Types についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
