find observations with nonconsecutive numbers
8 次查看(过去 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);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discrete Data Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!