Effacer les filtres
Effacer les filtres

Determine the start and end of a vector.

20 vues (au cours des 30 derniers jours)
Ferd
Ferd le 27 Sep 2016
Commenté : Ferd le 28 Sep 2016
When the variable starts incrementing above a threshold, that index is to be determined and also when the same variable starts decrementing below a certain threshold, the index is to be determined.
  2 commentaires
Walter Roberson
Walter Roberson le 27 Sep 2016
Are the two thresholds the same value?
Ferd
Ferd le 28 Sep 2016
Two different thresholds

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 28 Sep 2016
Try using diff() and strfind():
% Create random sample data.
v = randi(9, 1, 20)
thresh = 3; % Define the threshold.
% Find indexes where v is at or above the threshold.
d = (v>=thresh)
% Find the starting index where the signal starts above the threshold
% and then starts to fall below the threshold.
fallsBelow = strfind(d, [1, 0])
% Find the starting index where the signal starts below the threshold
% and then starts to rise above the threshold.
risesAbove = strfind(d, [0, 1])
  2 commentaires
Walter Roberson
Walter Roberson le 28 Sep 2016
This is a good approach when the thresholds are the same. Matters get more complicated when the thresholds are different. For example if you wanted to trigger at 1/4 Volt and to keep monitoring until you dropped to 0 V, then it becomes trickier.
Ferd
Ferd le 28 Sep 2016
Thanks! Yeah, had just set it up with two separate thresholds, d1 and d2. Its giving the results I'm looking for!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Operators and Elementary Operations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by