# draw a graph of peaks find peaks

조회 수: 2(최근 30일)
Lev Mihailov 2022년 7월 7일
답변: Image Analyst 2022년 7월 7일
I use the find peaks command, but it does not give me the exact coordinates for plotting
[pks,locs,w,p]=findpeaks(X(1026,:),FsY,'MinPeakProminence',2);
figure(1), clf
plot(Y,X(1026,:),'k-')
hold on
plot(locs,pks,'r*')
the graph is not created correctly, all red dots are shifted to the left
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

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

### 답변(2개)

Chunru 2022년 7월 7일
편집: Chunru 2022년 7월 7일
[pks,locs,w,p]=findpeaks(X(1026,:),FsY,'MinPeakProminence',2);
figure(1), clf
% plot(Y,X(1026,:),'k-')
plot(X(1026,:), Y, 'k-')
hold on
plot(X(1026, locs), pks,'r*') % <=============
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

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

Image Analyst 2022년 7월 7일
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;
xlabel('x');
ylabel('FsY')
% 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:

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

### 범주

Find more on Descriptive Statistics in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by