필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
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
GULZAR
GULZAR 2023년 9월 7일
More than two interval means. What is the procedure of this code.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Generation에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by