Creating a timeseries using number of rows

1 次查看(过去 30 天)
I want to create a timeseries in the format 'dd-mm-yyy hh:mm' and I want the granularity of data to be hourly.
For example, if my first entry is '01-01-2015 00.00', I want the second entry to be '01-01-2015 01:00'
I tried doing the following:
ts1.TimeInfo.StartDate = '04-Jan-2015 00:00'; % Set start date.
ts1.TimeInfo.Format = 'dd-mm-yyyy hh:mm';
ts1.Time = ts1.Time - ts1.Time(1);
but I am getting data by the minute. ie:
04-Jan-2015 00:01
04-Jan-2015 00:02
How to I solve this problem? ANy help would be appreciated.

采纳的回答

Ameer Hamza
Ameer Hamza 2020-10-19
Try something like this
t1 = datetime('04-Jan-2015 00:00', 'Format', 'dd-MM-yyyy HH:mm');
t2 = datetime('07-Jan-2015 00:00', 'Format', 'dd-MM-yyyy HH:mm');
t = t1:hours(1):t2;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Variables 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by