3次元データの行列要素と行及び列番号の取り出し
Show older comments
Accepted Answer
More Answers (1)
Tohru Kikawada
on 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
(略)
Categories
Find more on 行列および配列 in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!