0001 function sunupdown=sunUpDown(datemjd,lat,long,buffer)
0002
0003
0004
0005
0006
0007
0008 [year,month,day,hour,minute,second]=mjd2date(datemjd);
0009
0010 date = datenum(year,month,day,hour,minute,second);
0011 [rhr,rmin,shr,smin]=sunrise(day,month,year,lat,long);
0012 sunupdown=1;
0013 hourd=hour;
0014 mind=minute;
0015 timed = hourd+mind/60;
0016 time_rise = rhr+rmin/60;
0017 time_set = shr+smin/60;
0018
0019 time_up=mod(time_set-time_rise,24);
0020 time_diff = (mod(timed-time_rise-buffer/60,24));
0021
0022 if (time_diff<=time_up+buffer/60)
0023 sunupdown = 1;
0024 else
0025 sunupdown=0;
0026 end