Effacer les filtres
Effacer les filtres

how to find peaks value using specific time interval instead of indices ?

3 vues (au cours des 30 derniers jours)
i am loging data from scope to workspace
i have to find peaksvalue for a specific time interval, lets say 12 to 12.5 sec but problem is that i have to mention time indices instead of time interval in command
such as
b=(findpeaks(ScopeData2.signals.values(378343:382177)))
i dont want to use these indices 378343:382177, i want to use time interval 12 to 12.5
reason for not using indices is that different scenarios such as ( capacitor case or motor case ) in my model have different number of indices for this specific time interval
to 12.5 sec
is there any way to use time 12 to 12.5 seconds to find peaks instead of indices ??

Réponse acceptée

Star Strider
Star Strider le 5 Avr 2019
Try this:
t = linspace(0, 30, 1000); % Time Vector
y = sin(2*pi*t); % Signal
t_int = [12, 12.5]; % Time Interval
idx = find((t >= t_int(1)) & (t <= t_int(2))); % Indices Correspoinding To Time Interval
[pks,locs] = findpeaks(y(idx)); % Find Peaks In Time Imterval
adjlocs = locs + idx(1)-1; % Adjust ‘locs’ To Correct For Offset
figure
plot(t, y)
hold on
plot(t(adjlocs), pks, '^r')
hold off
grid
Experiment to get the result you want.
  3 commentaires
Star Strider
Star Strider le 5 Avr 2019
As always, my pleasure.
GULZAR
GULZAR le 7 Sep 2023
More than two interval means. What is the procedure of this code.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Aucun tag saisi pour le moment.

Community Treasure Hunt

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

Start Hunting!

Translated by