필터 지우기
필터 지우기

Plot the result of findpeaks.

조회 수: 7 (최근 30일)
Jonas Bender
Jonas Bender 2021년 12월 28일
댓글: Jonas Bender 2022년 1월 3일
Dear all,
I captured human motion data of side-by-side walking in numerous data sets. The filtered data looks like that:
Now, I used the function findpeaks to find peaks and location of the filtered data and stored it in a struct.
for i = 1:numel (data)
[pks_1,locs_1] = findpeaks (data(i).filt_first_last_transposed (1,:)); % find peak and location
data(i).peaks_1 = pks_1; % store it into the struct 'data' with the field name peaks_1
data(i).locs_1 = locs_1; % see above
[pks_2,locs_2] = findpeaks (data(1).filt_first_last_transposed (2,:));
data(i).peaks_2 = pks_2;
data(i).locs_2 = locs_2;
end
I am struggling how to plot the filtered data including the identified pks. In doing so, I can inspect, if identified peaks are correct.
Any suggestions or an easier way to get results?
Regards, Jonas
  댓글 수: 1
Image Analyst
Image Analyst 2021년 12월 28일
편집: Image Analyst 2021년 12월 28일
You forgot to attach your data. Make it easy for us to help you, not hard.
Is your second curve supposed to be data(1) and not data(i)?

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

채택된 답변

Image Analyst
Image Analyst 2021년 12월 28일
Perhaps this:
for i = 1:numel (data)
% Find peaks for first column of the i'th data set.
col1 = data(i).filt_first_last_transposed (1,:);
[peakValues1, indexesOfPeaks1] = findpeaks(col1); % find peak and location
data(i).peaks_1 = peakValues1; % store it into the struct 'data' with the field name peaks_1
data(i).locs_1 = indexesOfPeaks1; % see above
% Plot them
hold off;
plot(col1, 'b-', 'LineWidth', 2);
hold on;
plot(indexesOfPeaks1, peakValues1, 'cv', 'MarkerSize', 15, 'LineWidth', 2)
% Find peaks for second column of the i'th data set.
col2 = data(i).filt_first_last_transposed (2,:);
[peakValues2, indexedOfPeaks2] = findpeaks(col2);
data(i).peaks_2 = peakValues2;
data(i).locs_2 = indexedOfPeaks2;
% Plot them
plot(col2, 'r-', 'LineWidth', 2);
hold on;
plot(indexesOfPeaks2, peakValues2, 'mv', 'MarkerSize', 15, 'LineWidth', 2)
end
If it doesn't work, attach data in a .mat file
save('answers.mat', 'data');
with the paperclip icon.
  댓글 수: 1
Jonas Bender
Jonas Bender 2022년 1월 3일
Dear Mr/Mrs,
thanks for your helpful advice. It works perfectly.
Jonas

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by