Logical Indexing with Condition Involving Functions
Afficher commentaires plus anciens
Suppose I created a function F, and I want to find all elements a in an array A such that F(a) is some value of the function. Is there any way to do this with logical indexing (or some other method)? I tried to use idx = (F(A) == 1), but it has been giving me error messages about different numbers of elements. Thanks in advance!
2 commentaires
Stephen23
le 5 Mai 2021
"but it has been giving me error messages about different numbers of elements"
Please show the complete error message. This means all of the red text.
Andrew Anderson
le 5 Mai 2021
Réponses (1)
VBBV
le 5 Mai 2021
%if true
idx = find(A(a) == 1)
Use it with find function for element indices
2 commentaires
Stephen23
le 5 Mai 2021
Note that the question specifically requests logical indices, not linear indices.
Andrew Anderson
le 5 Mai 2021
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!