フィルターのクリア

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 Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by