Plot the result of findpeaks.
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jonas Bender
am 28 Dez. 2021
Kommentiert: Jonas Bender
am 3 Jan. 2022
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 Kommentar
Image Analyst
am 28 Dez. 2021
Bearbeitet: Image Analyst
am 28 Dez. 2021
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)?
Akzeptierte Antwort
Image Analyst
am 28 Dez. 2021
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.
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!