finding peaks when axis are non-uniform
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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')
0 commentaires
Réponse acceptée
Image Analyst
le 29 Nov 2020
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 commentaires
Image Analyst
le 1 Déc 2020
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.
Plus de réponses (1)
Mathieu NOE
le 29 Nov 2020
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
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!