Code covered by the BSD License  

Highlights from
Day Length

image thumbnail
from Day Length by Travis Wiens
Calculates the length of daylight for any day and latitude

day_length_example.m
Day=0:365;

Lat_auckland=-(36+51/60);%latitude in degrees
Lat_saskatoon=(52+7/60);
Lat_arctic=66+33/60;

hours_auckland=day_length(Day,Lat_auckland);
hours_saskatoon=day_length(Day,Lat_saskatoon);
hours_arctic=day_length(Day,Lat_arctic);


figure(1)

plot(Day,[hours_auckland;hours_saskatoon;hours_arctic])

xlabel('Day (counting from December solstice)')
ylabel('length of daylight (hours)')
legend('Auckland','Saskatoon','Arctic Circle')

Contact us at files@mathworks.com