3次元データの行列要素と行及び列番号の取り出し
Afficher commentaires plus anciens
Réponse acceptée
Plus de réponses (1)
Tohru Kikawada
le 29 Jan 2018
michio さんの方法で答えになっていると思いますが、こんな方法も使えるかもしれません。
rng('default'); % 毎度同じランダムシードを使う
A1 = rand(4,3,2) % サンプルデータ
[ii,jj,kk] = ind2sub(size(A1),1:numel(A1))
A2 = [ii(:),jj(:),kk(:),A1(:)]
実行結果
A1(:,:,1) =
0.8147 0.6324 0.9575
0.9058 0.0975 0.9649
0.1270 0.2785 0.1576
0.9134 0.5469 0.9706
A1(:,:,2) =
0.9572 0.4218 0.6557
0.4854 0.9157 0.0357
0.8003 0.7922 0.8491
0.1419 0.9595 0.9340
A2 =
1.0000 1.0000 1.0000 0.8147
2.0000 1.0000 1.0000 0.9058
3.0000 1.0000 1.0000 0.1270
4.0000 1.0000 1.0000 0.9134
1.0000 2.0000 1.0000 0.6324
2.0000 2.0000 1.0000 0.0975
(略)
1 commentaire
VAMOU
le 30 Jan 2018
Catégories
En savoir plus sur 行列および配列 dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!