Matching data and time with sample number
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all, i have a data for 24hrs with sampling frequency of fs= 500Hz (so t=1/fs:1/fs:1/fs*length(data)). Now i want to extract the data from a particular time. For example the start time of the data is "11/19/2015 18:00" and i want to find the point in "t" at "11/20/2015 6:34".Can someone please help me with this? I am new to Matlab and not sure how to use datevectors.
2 commentaires
Adam
le 28 Sep 2016
What format is your time data in exactly? If you used datavec then I assume it is just in an nx6 double array, but you refer to strings for your times which makes me think your data is in date string format instead.
Réponse acceptée
dpb
le 28 Sep 2016
Find the elapsed time and convert to number of samples--
>> t0='11/19/2015 18:00';target='11/20/2015 6:34'; % given example times
>> dt=datenum(target,'mm/dd/yyyy HH:MM')-datenum(t0,'mm/dd/yyyy HH:MM') % the time delta
dt =
0.5236
>> nSampTarget=fix(dt*24*3600*500)
nSampTarget =
22619999
>>
So, at approximately the 22,620,000th sample will be the beginning of the time history of interest. The originating timestamp will only allow you to locate a precise time down to somewhere around +/- 1 minute which, at 500 Hz, is a number of samples of +/-500*60 = +/30,000
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Fourier Analysis and Filtering 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!