Creating a timeseries using number of rows

2 views (last 30 days)
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.

Accepted Answer

Ameer Hamza
Ameer Hamza on 19 Oct 2020
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;

More Answers (0)

Categories

Find more on Random Number Generation in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!