# Indicate peak value of a signal in matlab plot

조회 수: 57(최근 30일)
Joseph Nikhil Raj Koppula 2019년 5월 23일
답변: Sergio Yanez-Pagans 2021년 8월 20일
Is there a way to indicate the max peak value of a signal in the plot itself rather than maually hovering the mouse over it?
I know that we can use the function 'findpeaks' to indicate the peaks of a signal, but is it possible to indicate/label the numerical value of that peak at that particular point?

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

### 채택된 답변

Shunichi Kusano 2019년 5월 24일
Does this meet your thought? I just changed the example of "findpeaks" a little.
%% sample signal generation
x = linspace(0,1,1000);
Pos = [1 2 3 5 7 8]/10;
Hgt = [3 4 4 2 2 3];
Wdt = [2 6 3 3 4 6]/100;
for n = 1:length(Pos)
Gauss(n,:) = Hgt(n)*exp(-((x - Pos(n))/Wdt(n)).^2);
end
PeakSig = sum(Gauss);
%% Plot the individual curves and their sum.
plot(x,Gauss,'--',x,PeakSig)
%% Use findpeaks with default settings to find the peaks of the signal and their locations.
[pks,locs] = findpeaks(PeakSig,x);
%% Plot the peaks using findpeaks and label them.
findpeaks(PeakSig,x)
text(locs-.03,pks+.3,num2str(pks')) % put the text on the plot
hope this helps.
##### 댓글 수: 1표시숨기기 없음
Joseph Nikhil Raj Koppula 2019년 5월 27일
Thanks a lot!!!

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

### 추가 답변(1개)

Sergio Yanez-Pagans 2021년 8월 20일

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

R2018b

### Community Treasure Hunt

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

Start Hunting!