MATLAB: Time increment and julian date

julian datelooptime increment

Hello everyone,
Here is my problem:
First I have a departure date:
date_ = ( 2011 08 18) % initialize
Let's say I have a loop as well, and within this loop I need to convert from calendar date to Julian date since I am using this information later to determine the geocentric position of the Sun rsun_.
For t = 0 : 30 min : 200 days % 200 days is the simulation time
date_ = date_ + t_; % how to add 30 minutes for each iteration and
keeping format (YYYY MM DD) for conversion to
Julian date
date__ = julian( date_ );
rsun_ = ephemeris_sun( date__ );
% after I can perform my calculations
My problem is: look comment in the loop.
Thanks a lot,
Rom

Best Answer

Create the initial date as a 1x6 vector:
od = [ 2011 08 18 0 0 0 ];
Then, to add 30 minutes at each iteration, add 30 to the fifth element:
od(5) = od(5) + 30;
now you can use juliandate to convert the information to a Julian date:
jd = juliandate(od);