Effacer les filtres
Effacer les filtres

Plot the result of findpeaks.

7 vues (au cours des 30 derniers jours)
Jonas Bender
Jonas Bender le 28 Déc 2021
Commenté : Jonas Bender le 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 commentaire
Image Analyst
Image Analyst le 28 Déc 2021
Modifié(e) : Image Analyst le 28 Déc 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)?

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 28 Déc 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.
  1 commentaire
Jonas Bender
Jonas Bender le 3 Jan 2022
Dear Mr/Mrs,
thanks for your helpful advice. It works perfectly.
Jonas

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by