4-D Matrix Indices Corresponding to an Entry Inequality

1 回表示 (過去 30 日間)
Paul Fishback
Paul Fishback 2015 年 6 月 17 日
編集済み: Matt J 2015 年 6 月 17 日
I have a 4-dim matrix, A, of size say 10-by-10-by-200-by-30.
I would like to find all 4-tuples [i,j,f,t] for which A(i,j,f,t)<.01 and store each 4-tuple [i,j,f,t] as a row in a matrix, call it "Entries." For example, if Entries had a row consisting of 5,4,120,8, then A(5,4,120,8)<.01.
I started J=find(A<=.01), which of course returns a vector, where each vector entry corresponds to a particular 4-tuple.
The problem I'm having is determining the correspondence. If A was 2-by-2, I would just use
[I_row, I_col] = ind2sub(size(A),J),
in which case Entries=[I_row,I_col].
It's the fact my matrix A is 4-dim that's causing my difficulty.

採用された回答

Matt J
Matt J 2015 年 6 月 17 日
編集済み: Matt J 2015 年 6 月 17 日
[Tuples{1:ndims(A)}]=ind2sub(size(A), J);
Entries=[Tuples{:}];
  1 件のコメント
Matt J
Matt J 2015 年 6 月 17 日
For further relevant reading, see Comma Separated Lists

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by