Borrar filtros
Borrar filtros

Matching data and time with sample number

2 visualizaciones (últimos 30 días)
Sowmya MR
Sowmya MR el 28 de Sept. de 2016
Respondida: dpb el 28 de Sept. de 2016
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 comentarios
Adam
Adam el 28 de Sept. de 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.
Sowmya MR
Sowmya MR el 28 de Sept. de 2016
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".

Iniciar sesión para comentar.

Respuesta aceptada

dpb
dpb el 28 de Sept. de 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

Más respuestas (0)

Categorías

Más información sobre Time-Frequency Analysis en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by