The sunset function determines the UTC (Coordinated Universal Time) when the sun just sets below the horizon, \gamma = -0,833\degree. 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] = sunset(day,coord)
Where:
Parameter | Description |
utc | Returns the UTC time in 'hh:mm:ss' format. |
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]. |
Examples
Determine UTC for sunset at 13.05.2020 in Berlin:
utc = sunset('13.05.2020')
Result:
utc = 18:52:07
Determine UTC and local time for sunset at 21.07.2025 in Berlin:
[utc,lct] = sunset('13.05.2020')
Result:
utc = 18:52:07 lct = 20:52:07
Determine UTC for sunset at 21.04.1988 in Athens:
utc = sunset('21.04.1988',[37.978 23.728])
Result:
utc = 15:51:27
Reference
Daylight in buildings. 2019.