Finding the peak position of a plot?

Hi,can anyone tell me how to find the peak of a plot . I have the code plot(sum(fill>0)); Now how to find the peak value of the plot??

댓글 수: 2

Sean de Wolski
Sean de Wolski 2011년 2월 7일
Don't overwrite the stock
fill
function
Andrew Newell
Andrew Newell 2011년 2월 7일
In other words, choose a different name for your variable FILL because it is the name of a MATLAB plot function.

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

 채택된 답변

Andrew Newell
Andrew Newell 2011년 2월 7일

0 개 추천

If sum(fill>0) is the thing you want the maximum of, you could use
[C,I] = max(sum(fill>0));
The C give the maximum value (or values, if you have a matrix) and I the position(s).

댓글 수: 3

Niranjan
Niranjan 2011년 2월 10일
All I need is to find the maximum position of the peak. Please have a look at the link for the figure.
https://picasaweb.google.com/lh/photo/4cX_xHOUkiW3GqBLe5XjdZOzMXS1UfqXPDW9N1lFu0w?feat=directlink
Walter Roberson
Walter Roberson 2011년 2월 10일
In your original problem statement, you asked to find the "peak value" of the plot, but now you are asking to find the "maximum position". The peak _value_ would be the maximum height, whereas the maximum position would be the x location at which it occurs.
Andrew's answer covers both possibilities: his C would be the height and his I would be the x value.
If all you need is the height, then you can simplify his code by a tiny bit,
C = max(sum(fill>0));
This really is about as fast as you are going to be able to get without resorting to mex, and since you only have about 120 columns I'm not sure you would be able to do any faster in mex (though you could do a mex version that used less memory.)
Niranjan
Niranjan 2011년 2월 11일
Thanks :)

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Blue에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by