Matching data and time with sample number
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Adam
2016-9-28
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.
采纳的回答
dpb
2016-9-28
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!