The suntime function calculates the Coordinated Universal Time (UTC) or local time for a given sun position and geographic location according to DIN EN 17037. The default geographical settings are set in the file “LT_location.mat”. Change the settings to your preferred location and set the file to read-only in order to prevent your settings from being overwritten with the default values in future versions.
Usage:
[utc,lct] = suntime(day,coord,target,value)
Where:
Parameter | Description |
utc | Returns the Coordinated Universal Time (UTC) |
lct | Returns the local time, offset to UTC is defined in LT_location.mat file. |
day | Specifies the date in ‘DD.MM.YYYY’ format. |
coord | Specifies the geographic coordinates, default is defined in LT_location.mat file, default Berlin: [13.326 52.514]. |
target | Specifies the target angle:'gamma1' = sun elevation angle: \gamma (first time)'gamma2' = sun elevation angle: \gamma (second time)'azimuth' = azimuth angle: \alpha 'sunrise' = sunrise (\gamma = -0.833)'sunset' = sunset (\gamma = -0.833) |
value | Specifies the target value. Note: for sunrise and sunset the value is automatically set to -0.833. |
Examples
UTC for sun position \alpha = 90° at 13.05.2022 in Berlin:
utc = suntime('13.05.2022',[],'azimuth',90)
Result:
utc = 06:01:31
UTC and local time for sunset at 13.05.2022 in Berlin:
[utc,localtime] = suntime('13.05.2022',[],'sunset')
See also: sunset
Result:
utc = 18:51:05 localtime = 20:51:05
UTC for sun positions \gamma_1 = 20° at 18.07.2021 in Athens:
utc = suntime('13.05.2022',[37.978 23.728],'gamma2',20)
Result:
utc = 14:26:51
Reference
Daylight in buildings. 2019.