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

2 vues (au cours des 30 derniers jours)
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 commentaire
Rik
Rik le 29 Mar 2021
Good for you. Do you also have a question? Have you tried anything?
The RunLength FEX submission may be helpful.

Connectez-vous pour commenter.

Réponses (1)

Matt J
Matt J le 29 Mar 2021
Modifié(e) : Matt J le 29 Mar 2021
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

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by