How to determine onset and offset for a continuous data?

조회 수: 9 (최근 30일)
lim xiang
lim xiang 2020년 12월 28일
답변: Suraj Kumar 2025년 4월 1일
Hi, I have a set of sinusoidal-like data as in attachment, may I know any functions to locate the onset and offset of peaks in each of the cycles?
I have tried 'ischange' and 'findchangepts', but not able locate the points precisely

답변 (1개)

Suraj Kumar
Suraj Kumar 2025년 4월 1일
Hi Lim,
To determine the onset and offset of peaks for each cycle in sinusoidal-like continuos data, you can go through the following steps and the attached code snippets with sample data:
1. Ensure your data is loaded into MATLAB workspace.
t = 0:0.01:10;
data = sin(2*pi*1*t) + 0.1*randn(size(t));
2. Use the 'findpeaks' function to locate the peaks in your data.You can adjust parameters like 'MinPeakProminence' to ensure you are capturing significant peaks.
For more information on 'findpeaks' function in MATLAB, please refer to the following documentation :
[peaks, locs] = findpeaks(data, 'MinPeakProminence', 0.5);
3. Then you can define criteria for onset and offset. A common approach is to use a threshold method where you identify points crossing a specific amplitude level before and after each peak.
threshold = 0.5;
onset_indices = find(data(1:end-1) < threshold & data(2:end) >= threshold);
offset_indices = find(data(1:end-1) >= threshold & data(2:end) < threshold);
4. Plot the data along with identified peaks, onset, and offset points to verify the results visually.
figure;
plot(t, data);
hold on;
plot(t(locs), peaks, 'ro');
plot(t(onset_indices), data(onset_indices), 'g^');
plot(t(offset_indices), data(offset_indices), 'kv');
xlabel('Time');
ylabel('Amplitude');
title('Sinusoidal Data with Peaks, Onset, and Offset');
legend('Data', 'Peaks', 'Onset', 'Offset');
Hope this works for you!

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by