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
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.
Sowmya MR
Sowmya MR 2016-9-28
I do not have a "time vector". I just have a ECG data with fs=500hz for 24hrs and the starting time of the recording is "11/19/2015 18:00". Now i need to extract the ECG data from time "11/20/2015 6:34".

请先登录,再进行评论。

采纳的回答

dpb
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 个)

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by