Converting time to sample numbers

6 ビュー (過去 30 日間)
Sunil
Sunil 2017 年 10 月 6 日
コメント済み: Sowmya MR 2017 年 10 月 7 日
Hi,
I have an ECG recording which is approximately 2 days long. The time stamps are continuous (after 24hrs it becomes 25hr and so on). Now i have a start time of the recording, length of the data and sampling frequency. Is it possible to create a time vector using this?
Lets say: Fs=250Hz, Start time = 08:33:05 and total length of the data is 28hours?

採用された回答

Cam Salzberger
Cam Salzberger 2017 年 10 月 6 日
Hello Sunil,
Quite easily actually. Just convert the start time to a datetime, and then add the timesteps as duration values to the initial time. Something like:
startTime = datetime('08:33:05'); % Defaults to today's date, but you can add a date
Fs = 250; % Hz
period = 1/Fs; % seconds
timesteps = startTime+seconds(0:period:28*60*60*Fs);
Now the issue is that the datetime array would be 6300000001 elements long, which is generally too much memory. So depending on what you want to do with it, I'd suggest creating it in smaller segments and writing it to a file or manipulating data with that.
-Cam
  1 件のコメント
Sowmya MR
Sowmya MR 2017 年 10 月 7 日
Thank you.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by