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.