Can I count the number of integers in an index and store it in a variable?
1 回表示 (過去 30 日間)
古いコメントを表示
index = find([X] == 1)
If I have an array X and I use index to find the where the value 1 is in the array and it gives me the following output that there are 2 places where the number 1 is found at spot [3;25]
index =
3
25
Can I store the value 2 in a variable that it found 2 integers?
1 件のコメント
Stephen23
2017 年 9 月 17 日
The find is not required (logical indexing is often much more efficient than using find) The square brackets are also not needed.
nnz(X==1)
採用された回答
その他の回答 (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!