draw a graph of peaks find peaks

13 Ansichten (letzte 30 Tage)
Lev Mihailov
Lev Mihailov am 7 Jul. 2022
Beantwortet: Image Analyst am 7 Jul. 2022
I use the find peaks command, but it does not give me the exact coordinates for plotting
figure(1), clf
hold on
the graph is not created correctly, all red dots are shifted to the left
Thanks in advance
p.s. if I use only find peaks, the graph builds the correct one for me, but I need to show these peaks in a different color

Antworten (2)

Chunru am 7 Jul. 2022
Bearbeitet: Chunru am 7 Jul. 2022
figure(1), clf
% plot(Y,X(1026,:),'k-')
plot(X(1026,:), Y, 'k-')
hold on
plot(X(1026, locs), pks,'r*') % <=============

Image Analyst
Image Analyst am 7 Jul. 2022
Try this:
xv = X(1026, :); % All columns of row 1026
[peakValues, indexesOfPeaks, w, p] = findpeaks(xv, FsY, 'MinPeakProminence', 2);
% Plot original data in black
hFig = figure;
plot(xv, Y, 'k-', 'LineWidth', 2)
grid on;
% Now plot red stars over the peaks.
hold on
plot(xv(indexesOfPeaks), peakValues,'r*');
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:


Community Treasure Hunt

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

Start Hunting!

Translated by