I want to know the starting index of consecutive negative elements and also thier count.

1 次查看(过去 30 天)
I just have an array of 76140 data. What to do, if I want to know the starting index of consecutive negative elements and also thier count. Thank you in advance

回答(1 个)

Matt J
Matt J 2021-3-29
编辑:Matt J 2021-3-29
Using this File Exchange submission,
yourVector = [0 -3 -4 1 2 7 -9 -10 -11]; %example
G=groupTrue(yourVector<0);
startingIndex = groupFcn(@(x) x(1) , 1:numel(G), G),
startingIndex = 1×2
2 7
count = groupFcn(@numel , G, G),
count = 1×2
2 3

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by