sundial

Shadow positions for a horizontal, vertical or tilted plane sundial taking into account times the dial is illuminated
39 Downloads
Updated 2 Feb 2022

View License

Given an array of times and the latitude of a plane sundial, sundial.m computes the corresponding angles of the shadow on the dial.
The sundial may be at any orientation - both bearing and tilt may be specified - but there are simple argument sequences for the common cases of horizontal and vertical sundials.
The solar declination may be specified explicitly as an angle or as a date, or it may be allowed to default. The default is to use, for each time, a declination for which the dial is illuminated on some day of the year. Times for which the dial is never illuminated return NaN.
The time may be specified as either true solar time (normally used for laying out a sundial) or as mean solar time (clock time). A longitude correction may be applied.
The style (the shadow-casting edge of the gnomon) may be aligned with the celestial poles, as is usual, or may be perpendicular to the plane of the dial.
The coordinates of the shadow of the tip of the gnomon, and of the tip of the gnomon itself, may be returned as additional results.
The help information includes simple examples and an outline of the mathematical relations underlying the code. Fuller examples are in sundialExamples.m.
The function uses an arguments block so will not run in releases earlier than R2019b. The examples use name=value syntax so require R2021a or later.
Ancillary functions solarDeclination and equationOfTime are included.

Cite As

David Young (2024). sundial (https://www.mathworks.com/matlabcentral/fileexchange/105220-sundial), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2021b
Compatible with R2019b and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
2.4.0

Added result to enable correct alignment of gnomon.

2.3.0

Allowed Dec parameter to be array same size as T as well as scalar

2.2.0

Option for polar or normal orientation of the style.

2.1.0

Extended examples and moved to separate file

2.0.1

Now allows sundial to be at a pole.
Fixed time zone bugs: first argument can be zoned or unzoned datetime, and time zone offsets for longitude correction no longer use pre-1883 values.

2.0.0

Tilt argument added.
Options for longitude correction and for specifying time as mean solar time (clock time).
Simplified arguments for simple cases.
Further examples.
Other planets allowed.
Error that affected coordinate but not angle results fixed.

1.0.2

Note on local solar time added to help comments.

1.0.1

Added a note about local solar time to the comments.

1.0.0