Filter löschen
Filter löschen

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

3 Ansichten (letzte 30 Tage)
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 ??

Akzeptierte Antwort

Star Strider
Star Strider am 5 Apr. 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 Kommentare
GULZAR
GULZAR am 7 Sep. 2023
More than two interval means. What is the procedure of this code.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by