How to create a time series for storing data in each time step

I have solar irradiance data. I have to create a time based loop from 8 Am to 4 Pm, Including every min of the required time interval. How can i generate the required time and store the data accordingly. Like 8 am = 1 min = . . . 59 min= 9am = . . . . . 4PM

Answers (1)

A) Use Matlab datenum serial date numbers w/ an arbitrary origin --
>> t=datenum(2010,1,1,8,[0:8*60],0); % 1Jan2010 8AM beginning
>> datestr(t(59:62),'hh:MM:ss') % illustrate minute rollover at hour
ans =
08:58:00
08:59:00
09:00:00
09:01:00
>> [t(59:62)-t(1)]' % fractional days internally relative origin
ans =
0.0403
0.0410
0.0417
0.0424
>>
B) Simply use
t=[1:60*8]';
for sequential minutes from beginning. Convenient for 1:n addressing but not so much for display purposes, etc., if want to plot against time of day, etc., ...
For the latter, see
doc datetick % and friends for formatting the time axis as desired.

Categories

Asked:

on 11 Nov 2013

Answered:

dpb
on 11 Nov 2013

Community Treasure Hunt

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

Start Hunting!