3次元データの行列要素と行及び列番号の取り出し
이전 댓글 표시
채택된 답변
추가 답변 (1개)
Tohru Kikawada
2018년 1월 29일
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
(略)
카테고리
도움말 센터 및 File Exchange에서 行列および配列에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!