How to add time duration of peaks in plot
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi
I have a a vector containing time duration of each peak duration
g = [0.8432 0.6010 0.2447 0.2274 0.1081 0.1025 0.0818 0.0800];
and I want to that duration figure in my signal plot as the figure below:
So,how can I do it please
0 Commenti
Risposte (2)
Star Strider
il 13 Giu 2022
I am not certain what you want.
Try this —
x = linspace(0, 20, 250);
ctrv = rand(3,1)*18;
y = sum(exp(-(x-ctrv).^2./rand(3,1))); % Generate Gaussian Peaks With Random Widths & Locations
[pks,locs,wdth] = findpeaks(y, 'WidthReference','halfheight'); % Calculate Peak Locations & FWHM Values
figure
plot(x, y)
grid
text(x(locs), pks/2, compose('%.1f',wdth), 'Horiz','center', 'Vert','bottom') % Write The FWHM Values At The Appropriate Locations On The Plot
This writes the full-width-half-maximum values at the coordinates of those values. See the documentation on the text function for details. Make appropriate changes to work with your data.
.
4 Commenti
Image Analyst
il 13 Giu 2022
bar(wdth);
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
Star Strider
il 13 Giu 2022
@Abdelhakim Souidi — With respect to your earlier Comment, my code works correctly, as demonstrated. I have no idea what you are doing, so I cannot determine what the problem is with your using it.
Image Analyst
il 12 Giu 2022
Not sure how you're defining the width but you can fall down each side of the peak (with a for loop) until you hit a certain level, like 0.5. Or do it like this:
props = regionprops(signal > 0.5, 'Area');
peakWidths = [props.Area]
Or you can fall down from the peak (on each side with a for loop) until the value no longer decreases.
0 Commenti
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!