2 vues (au cours des 30 derniers jours)
Amir Cawich le 26 Fév 2023
Réponse apportée : dpb le 26 Fév 2023
I am trying to draw a line between the peaks of a signal. I am using the following criterias: first locate all peaks that are higher than 150 using the MinPeakHeight function.However, there are regions where the peaks do not reach the 150 threshold. so I find the maximum peak within every interval of 25 using MInPeak Distance. Use the image for referal. The orange line is the one obtained using the threshold of 150 (produces a 1*9 matrix) and the yellow one is the one using a distance of 25 (produces a 1*13). Ideally i would like to combine both of these lines into one. But it becomes tricky having both the [pks,locs] like coordinates. Is there any way it can be done. I was also thinking of using a for loop and if statement to set boundaries but i am not sure this is the best way. I am not sure if it can be done. any ideas are welcome.
[pks,locs]= findpeaks(new,'MinPeakHeight',150);
[pks2,locs2]= findpeaks(new,'MinPeakDistance',25);
%%Using For loop i was trying something like this
for i=1:25:100
[pks,locs]= findpeaks(new(i),'MinPeakHeight',150);
if pks ==[]
[pks,locs]= findpeaks(new(i),'MinPeakDistance',25);
end
end
0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Réponses (1)

dpb le 26 Fév 2023
You have to add the starting location of your subsection to the returned location if you subset the overall signal, The loop you show will only pass a point; you would need to set a width/length of the timeseries to do this way.
Try something like
[pks1,locs1]=findpeaks(new,'MinPeakHeight',150);
[pks2,locs2]= findpeaks(new,'MinPeakDistance',25);
locs=[locs1 locs2]; % combine the two sets into one
pks=[pks1 pks2];
[locs,iloc]=unique(locs); % find the unique locations between the two
pks=pks(iloc); % get corresponding values
It would be beneficial and folks would probably chime in with far more creative solutions if you would attach the signal and define more specifically just what is the criteria by which a peak is/is not to be chosen. findpeaks is pretty flexible; more tweaking on its inputs might make things "more simpler" and, in particular, more repeatable from trace to trace.
0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Catégories

En savoir plus sur Descriptive Statistics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by