フィルターのクリア

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

3 ビュー (過去 30 日間)
zubair younas
zubair younas 2019 年 4 月 5 日
コメント済み: GULZAR 2023 年 9 月 7 日
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 ??

採用された回答

Star Strider
Star Strider 2019 年 4 月 5 日
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 件のコメント
Star Strider
Star Strider 2019 年 4 月 5 日
As always, my pleasure.
GULZAR
GULZAR 2023 年 9 月 7 日
More than two interval means. What is the procedure of this code.

サインインしてコメントする。

その他の回答 (0 件)

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by