Looking for a way faster than find?
6 ビュー (過去 30 日間)
古いコメントを表示
Dear All,
I have an array A. I want to find out the index of those "1" entries in the array A.
For example, A = [1 2 5 1 3 2 8 10 1]. I want to find out the indecis of those "1" in A.
I used logical indexing to find the location but cannot get the indecis.
a = A == 1;
a = [1 0 0 1 0 0 0 0 1].
How can I find the indecis of nonzero in a?
Thanks.
Benson
0 件のコメント
採用された回答
Joseph Cheng
2021 年 6 月 21 日
編集済み: Joseph Cheng
2021 年 6 月 21 日
without doing some testing to actually test if its faster you can use the found 1's in a to only select a list of indexes
A = [1 2 5 1 3 2 8 10 1];
a = A==1
inds = [1:numel(A)];
inds(a)
2 件のコメント
Joseph Cheng
2021 年 6 月 21 日
but it did answer your i "I used logical indexing to find the location but cannot get the indecis... How can I find the indecis of nonzero in a?"
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!