find observations with nonconsecutive numbers
11 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
その他の回答 (1 件)
JESUS DAVID ARIZA ROYETH
2017 年 7 月 8 日
like this:
A=[55; 56; 57; 58; 26; 27; 28];
observations=A([1; diff(A)]~=1);
2 件のコメント
JESUS DAVID ARIZA ROYETH
2017 年 7 月 8 日
A=[55; 56; 57; 58; 26; 27; 28];
observations=find([1; diff(A)]~=1);
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!