Problem 59816. Sun angle
Determine the angle of the sun above the horizon based on the time of day.
Assumptions: the sun rises in the East at 6h00, corresponding to an angle of 0° degrees; reaches its zenith at 12h00, with an angle of 90° degrees; and sets at 18h00, with an angle of 180° degrees.
Input: The time of day represented as a list [hh, mm], where and .
Output: The angle of the sun above the horizon, in degrees, rounded to 2 decimal places. If the input time falls within the night hours (before 6h00 or after 18h00), your function should return 'Night'.
Example:
- sun_angle([7,0]) should return 15.00
- sun_angle([12,15]) should return 93.75
Solution Stats
Problem Comments
-
1 Comment
Dyuman Joshi
on 15 Jun 2024
Added a test suite to cover time before 6 am and rescored solutions.
Solution Comments
Show commentsProblem Recent Solvers13
Suggested Problems
-
Make the vector [1 2 3 4 5 6 7 8 9 10]
49334 Solvers
-
6119 Solvers
-
Longest run of consecutive numbers
5591 Solvers
-
We love vectorized solutions. Problem 1 : remove the row average.
823 Solvers
-
255 Solvers
More from this Author53
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!