- If you specify a location vector, x, then 'MinPeakDistance' must be expressed in terms of x. If x is a datetime array, then specify 'MinPeakDistance' as a duration scalar or as a numeric scalar expressed in days.
- If you specify a sample rate, Fs, then 'MinPeakDistance' must be expressed in units of time.
- If you specify neither x nor Fs, then 'MinPeakDistance' must be expressed in units of samples.
Making two peaks into one
8 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi
How can I make two peaking values into the highest.
I have these vectors (one double and one duration) showing the duration of the peaks (when the curve crosses the red threshold).
However some peaks have two peak values, making the double vector one element bigger than the duration vector. I want the vectors to be of the same length so only the highest peaking value of each peak show. So in this case row 9 of the max_val should be removed.
EFFEKT= 8760x1 double %One value for every hour of the year
Abonnemang=24200; %threshold value
t=8760x1 datetime %Every hour of the year
[max_val,locs] = findpeaks(EFFEKT,'MinPeakHeight',Abonnemang); % find the peak and its x axis location
[t0_pos1,s0_pos1,t0_neg1,s0_neg1]= crossing_V7(EFFEKT,t,Abonnemang,'linear'); % positive (pos) and negative (neg) slope crossing points
peak_width = t0_neg1- t0_pos1;
peak_width =peak_width
peak_width
max_val
0 Commenti
Risposta accettata
Mathieu NOE
il 6 Apr 2023
hello again
have a look at the help of findpeaks;
use this argument of findpeaks to keep only the tallest peak :
MinPeakDistance — Minimum peak separation
0 (default) | positive real scalar
Minimum peak separation, specified as a positive real scalar. When you specify a value for 'MinPeakDistance', the algorithm chooses the tallest peak in the signal and ignores all peaks within 'MinPeakDistance' of it. The function then repeats the procedure for the tallest remaining peak and iterates until it runs out of peaks to consider.
Use this argument to have findpeaks ignore small peaks that occur in the neighborhood of a larger peak.
3 Commenti
Mathieu NOE
il 11 Apr 2023
hello
look at the doc
you can combine multiple options (arguments) in one single call to findpeaks
if you use 'MinPeakDistance' with value = 30, that means you want no peaks that are closer than 30 samples (on the x axis) , so if you have 2 (and more) close by peaks, you can use that argument to keep only one (with the highest peak value)
NB you should combine the arguments :
[max_val,locs] = findpeaks(EFFEKT,'MinPeakHeight',Abonnemang,'MinPeakDistance',30);
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!