Maximum value from data
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hey guys,
i have a problem with the maxk and findpeaks function from matlab. I have a dataset with thousands of items and I want to display the 25 largest items in the order they appear in the dataset. First i used the maxk function to get the 25 highest values. so far so good i got my 25 values but in the wrong order. Then i tried to use the findpeaks function on my outgoing dataset and used for the 'MinPeakHeight' the lowest value from the maxk funtion. But in the end I did not have 25 items but only 22. What did i wrong?
n = 25;
Peaks = Output.Results_interval_analysis.Untitled.max_abs_in_V;
n_Peaks = maxk(Peaks,n);
% so here i got my 25 values from high to low
[pks_Peaks, locs_Peaks] = findpeaks(Peaks,'MinPeakHeight',n_Peaks(1, n))
% after this step i only got 22 values
0 commentaires
Réponse acceptée
dpb
le 3 Fév 2021
findpeaks uses more logic internally than just height; it will consider points inside the peak width as being part of the larger peak even if they are numerically greater than the minimum maximum you set. It isn't the tool for determining the N largest values in an array irrespective of relationship spatially; that is a job for maxk. As the other responder noted; use the optional location vector returned to rearrange in ordinal order.
Although it does seem as though an optional 'stable' parameter could be introduced a la unique to return values in their natural order would be a reasonable enhancement.
0 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!