find observations with nonconsecutive numbers
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
wesso Dadoyan
le 8 Juil 2017
Réponse apportée : Walter Roberson
le 8 Juil 2017
A=[55; 56; 57; 58; 26; 27; 28]
I want to find the observations in A where the two consecutive observations are not equal. In this case it should be the 5th observation since 26~=58. How can I do that elegantly?
0 commentaires
Réponse acceptée
Plus de réponses (1)
JESUS DAVID ARIZA ROYETH
le 8 Juil 2017
like this:
A=[55; 56; 57; 58; 26; 27; 28];
observations=A([1; diff(A)]~=1);
2 commentaires
JESUS DAVID ARIZA ROYETH
le 8 Juil 2017
A=[55; 56; 57; 58; 26; 27; 28];
observations=find([1; diff(A)]~=1);
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!