time increment and julian date
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Romain W
el 7 de Jul. de 2011
Comentada: Steven Lord
el 31 de Ag. de 2022
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
0 comentarios
Respuesta aceptada
Laura Proctor
el 7 de Jul. de 2011
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;
jd = juliandate(od);
1 comentario
James Tursa
el 9 de Jul. de 2011
Side Note: That only works if od is in Ephemeris Time. If od is in UT then it doesn't account for leap seconds. If od is not in UT then it won't account for time zone differences. Don't use this method for precision work.
Más respuestas (2)
James Tursa
el 7 de Jul. de 2011
Caution: To be precise, a sun position algorithm will need a Julian Date based on Ephemeris Time. So you would need to convert the date vector from whatever time convention it is in (e.g., your local time, or UT, or whatever) to an Ephemeris Time before doing the Julian Date conversion. Basically, planetary calculations need a continuous time to work with, and local times, UT, etc do not meet that requirement. What time convention is your date vector in?
0 comentarios
Argiris
el 31 de Ag. de 2022
following is a code that increases the time every 10 seconds and has an output a table A=[YY,MM,DD,HH,MM,SS].
You can then easily manipulate the matrix to any spesific form by combining stings and variables.
e.g
A(1)+"/"+A(2)+"/"+A(3)+" "+A(4)+":"+A(5)+":"+A(6)
time= [2022,1,1,0,0,0]; %Initiallize time and date
c=0;
c1=0;
c2=0;
c3=0;
c4=0;
j=0;
time_increment=10; %time increment in seconds
for i=0:65000
if time(6)<=60
time(6)=time(6)+time_increment;
c=c+1;
end
if time(6)>=60
time(6)=0;
time(5)=time(5)+1;
c=0;
c1=c1+1;
end
if time(5)>=60
time(5)=0;
time(4)=time(4)+1;
c1=0;
c2=c1+1;
end
if time(4)>=24
time(4)=0;
time(3)=time(3)+1;
c2=0;
c3=c3+1;
end
if time(3)>=12
time(3)=0;
time(2)=time(2)+1;
c3=0;
c4=c4+1;
end
j=j+1;
A(j,1)=time(1);
A(j,2)=time(2);
A(j,3)=time(3);
A(j,4)=time(4);
A(j,5)=time(5);
A(j,6)=time(6);
end
1 comentario
Steven Lord
el 31 de Ag. de 2022
Rather than doing the date and time arithmetic yourself, just let datetime handle it.
startTime = datetime(2022,1,1)
Let's say that I want ten date and time values spaced 10 minutes apart, starting at startTime.
increments = (0:9).'*minutes(10);
theTimes = startTime + increments
If we wanted Julian dates:
format longg
theJulianDates = juliandate(theTimes)
Ver también
Categorías
Más información sobre Dates and Time en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!