多次元行列をページ方向にスライスして2次元配列を得る方法
23 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Yuki Koyama
le 15 Jan 2021
Commenté : Yuki Koyama
le 18 Jan 2021
多次元行列をページ方向にスライスして2次元配列を得る簡潔な方法はどうやりますか?
たとえば以下のように実行すると、ページ方向のインデックスごとに表示され、行列にはなりません。
A=randi(10,[5 5 5]);
A(1,:,:)
ans =
ans(:,:,1) =
1 9 10 10 2
ans(:,:,2) =
3 9 1 8 6
ans(:,:,3) =
2 5 8 10 3
ans(:,:,4) =
6 8 9 5 3
ans(:,:,5) =
1 3 5 9 7
これを行列として出力したい場合はどのような方法で行うのが一般的でしょうか?
0 commentaires
Réponse acceptée
Shunichi Kusano
le 15 Jan 2021
squeeze関数でイメージ通りになるでしょうか。
squeeze(A(1,:,:))
ans =
9 8 3 4 2
1 8 5 4 7
2 9 8 3 5
2 5 10 1 9
7 5 9 2 2
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!