How to find the latest peak value of a curve.

조회 수: 2 (최근 30일)
Jean-Baptiste DUCAT
Jean-Baptiste DUCAT 2016년 12월 13일
댓글: Jean-Baptiste DUCAT 2016년 12월 13일
Hello,
I have a problem, i want to find the latest peak value of the following power curve. It is not the maximum power point, i've already found it earlier. But i should compare the latest value P(end) with P(end-1) and if P(end)<P(end-1) we should continue like this... to reach the point where P(i)>P(i-1) to come one value before, it will give me the latest peak power value.
Thank's for your help ;) Jb
  댓글 수: 2
Jean-Baptiste DUCAT
Jean-Baptiste DUCAT 2016년 12월 13일
I've tried with findpeak function but it return me an error message:
>> PV=plot(U,P)
PV =
Line with properties:
Color: [0 0.4470 0.7410]
LineStyle: '-'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [1x262 double]
YData: [1x262 double]
ZData: [1x0 double]
Show all properties
>> findpeaks(PV)
Error using findpeaks
Expected Y to be one of these types:
numeric
Instead its type was matlab.graphics.chart.primitive.Line.
Error in findpeaks>parse_inputs (line 191)
validateattributes(Yin,{'numeric'},{'nonempty','real','vector'},...
Error in findpeaks (line 134)
= parse_inputs(Yin,varargin{:});
Jiro Doke
Jiro Doke 2016년 12월 13일
findpeaks takes a numeric vector as the input. That's what the error "Expected Y to be numeric" means.

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

채택된 답변

Jiro Doke
Jiro Doke 2016년 12월 13일
[pk,loc] = findpeaks(P(end:-1:1),'NPeaks',1);
[U(end-loc+1) pk]

추가 답변 (1개)

Adam
Adam 2016년 12월 13일
If you have the Signal Processing Toolbox just use findpeaks, if not since you only want the last peak even a simple loop running from the end of the trace forward and stopping when you reach a point where you stop increasing would do the job.
  댓글 수: 1
Jean-Baptiste DUCAT
Jean-Baptiste DUCAT 2016년 12월 13일
I've already done that but it's ok i've the right answer now thank's for all ;)

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

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by