Find where certain sequence of true/falses is placed inside a logical array
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Enrico Gambini
le 13 Oct 2022
Modifié(e) : Enrico Gambini
le 13 Oct 2022
Hello!
Assume that I have the following logical array:
x=[false;false;true;true;true;true;true;false;true;true;true]'
I would like to construct a logical array which returns true at the index where the sequence [true;false;true] is found
Hence the result would look like this
result=[false;false;false;false;false;false;true;false;false;false;false]'
Hope that the question is clear, thank you!
0 commentaires
Réponse acceptée
David Hill
le 13 Oct 2022
x=[false;false;true;true;true;true;true;false;true;true;true]';
f=strfind(x,[1 0 1]);
result=zeros(size(x));
result(f)=1
1 commentaire
Enrico Gambini
le 13 Oct 2022
Modifié(e) : Enrico Gambini
le 13 Oct 2022
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!