finding the duration of signal peak period
1 view (last 30 days)
Show older comments
HI below image represents data from video frames and has 4 peaks, the (x-axis) is the frame numbers, (y-axis) is the data values . how the duration of each peak can be found in seconds ?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161752/image.jpeg)
0 Comments
Answers (2)
Star Strider
on 15 Mar 2017
Edited: Star Strider
on 15 Mar 2017
Use the findpeaks function on the negative of your signal, and experiment with the name-value pair options, such as 'WidthReference'. Then have it return all 4 outputs:
[pks,locs,w,p] = findpeaks(-data, ... );
9 Comments
Star Strider
on 20 Mar 2017
I am not certain what your data actually represent. The ‘units’ of your peak locations and widths will be in terms of whatever you specify. If you specify nothing, they will be in terms of indices of your data vector. If your x-axis is time, ‘locs_smoothed’ and ‘widths_smoothed’ would be in units of time. The ‘proms_smoothed’ units will be in whatever your y-axis is.
If each plotted data point in your plot is some point (or a point representing some data in the full frame) in what I assume is your video, and those are presented at 30 fps, then your sampling frequency, ‘Fs’, is 30 Hz. The number of frames you have is not important with respect to your sampling frequency.
If the x-axis in your plot are indices, you can substitute your time vector directly to get it and all values derived from it in units of time.
Brian Mabe
on 5 Jun 2017
I am having a similar problem with the following: I need to calculation the duration and number of peaks in the data plotted by the given code:
clear clc load Time_X.txt load Turbid_Y.txt x=Time_X; y=Turbid_Y; t=[x,y]; i=1; a=0; b=0; while b==0 if t(i,2)>=0 if y(i)>=55 a=a+1; % disp(y(i)) value(a)=y(i); end i=i+1; end if i==14513 b=1; end
end
scatter(x,y,'.') hold on plot([0 31], [55 55]) xlim([0 31]); ylim([0 190]); if y>55 disp('y') end
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!