필터 지우기
필터 지우기

finding peaks when axis are non-uniform

조회 수: 3 (최근 30일)
Amin
Amin 2020년 11월 27일
댓글: Image Analyst 2020년 12월 1일
I have been using “findpeaks” to locate and plot the peaks that have a prominence of at least 0.05.
findpeaks(data,position,'MinPeakProminence',0.00005,'Annotate','extents')
My current data “position” values are generally increasing but not strictly. As expected I get the following error:
“Error using findpeaks. Expected X to be strictly increasing.”
Is there another way to find the max values that have minimum peak prominence of 0.05?
I would appreciate any suggestion.
in the example below (data and position attached) findpeak is ignoring the position and it is using indeces instead. This is due to not strickly increasing / nonlinear position values (changing position vector to a linearly spaced vector is not an option). The general trend of position data is increasing.
figure(1);
plot(position,data)
findpeaks(data,position,'MinPeakProminence',0.00005,'Annotate','extents')

채택된 답변

Image Analyst
Image Analyst 2020년 11월 29일
I've never used a second input argument like that but if it wants it increasing, then try this:
[sortedX, sortOrder] = sort(x, 'ascend');
% Not sure if PeakSig also needs to be sorted the same way. But if it does:
%PeakSig = PeakSig(sortOrder);
[peakValues, indexesOfPeaks] = findpeaks(PeakSig, sortedX,'MinPeakProminence',0.05,'Annotate','extents')
  댓글 수: 6
Amin
Amin 2020년 11월 30일
Thanks for your help. The second plot is what I was looking for ( .vs X). For some reason my plotting lines and how I used findpeak was totally ignoring the X when plotting (I was getting .vs index plot and the error with X). Would you by any chance know how to get prominence and width displayed on the plots same as the image below?
Image Analyst
Image Analyst 2020년 12월 1일
No - I've never done that before. I'd have to read the documentation just like you, but you can do that as well as I can.

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

추가 답변 (1개)

Mathieu NOE
Mathieu NOE 2020년 11월 29일
hi
my 2 cent suggestion if x is not strictly increasing, resample your data on a vector that is 100% sure strictly increasing
like this : create a new x data vector , linearly spaced, 100 values and interpolate the new y data on it
new_x_data = linspace(min(x),max(x),100); % my new x data
new_y_data = interp1(x,y,new_x_data) % my new y data
  댓글 수: 1
Amin
Amin 2020년 11월 30일
Thanks for your comment. Unfortunately, resampling is not the solution given that the collection of position data is intentionally none linear. sometimes a section needs denser sampling (closer position data), sometimes there are few sample at the same position, and rarely due to positional uncertainty x2>x1. However, the general trend is in increasing order. By resampling points of interest will not be in their actual location anymore.

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

카테고리

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