identifing the beginning and the end of a series
1 次查看(过去 30 天)
显示 更早的评论
Hi,
I have long vectors that have the following structures of zeros and ones: 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 How can I identify the 0 that comes before the series of ones? i.e observation 1 and 14. Using the same logic, how can I identify the end of series of ones i.e observations 8 and 21?
0 个评论
采纳的回答
Wayne King
2012-4-27
I = find(diff(x)==1);
J = find(diff(x)== -1);
I is 1 and 14, J is 8 and 21
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 System Identification Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!