Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help solve by MATLAB 1. The Lunar Phase Calculator. In this problem, you will construct a script that returns the lunar phase for a
Please help solve by MATLAB
1. The Lunar Phase Calculator. In this problem, you will construct a script that returns the lunar phase for a user- specified date. We can quickly estimate the lunar phase by knowing two things: (i) the number of days between the user-input date and a known new-moon date (in this case, we will use the new moon that occurred on January 1, 1900) and (ii) the number of days in each lunar revolution. You program should: (a) Take 3 separate command window inputs for a given date in the following format: MMM DD YYY The month input must be capitalized. Ensure that your code requests the input in the order shown below and that the inputs are all taken as a string, which maximizes our opportunities for error checking (i.e.,input ('...','s')). Please enter the month as MMM (e.g. DEC): Please enter the day as DD (e.g. 21): Please enter the year as YYYY (e.g. 2012): (b) Check the validity of the input and return an error if necessary. If the user inputs a non-numeric value or does not follow the formatting specification (e.g. YYYY as 19a6 or DD as 7 vs. 07) or inputs a date that does not exist (e.g. MAY 32 2000, FEB 29 2019, or SEP .5 -354), return an error message to the command window and end the function. Design your program to work for year values from 1900 to 9999. Be sure to take leap years into account when performing your checks. (c) Calculate the elapsed number of days since the new moon. To easily calcu- late the elapsed number of days since January 1, 1900, we'll first convert the user-input date into its corresponding Julian Day Number, J, an astronomical quantity indicating a continuous integer count of days past 4713 B.C. 153m+2|+ 365y + L] L J = day +| + L 32045 400 where y = year - a + 4800 month + 12a - 3 and the offset value, a, is set to 1 for January and February, and 0 for all other months. Once the Julian Day Number of the input date is calculated, the elapsed number of days can be calculated with a simple subtraction, AJ = Jinput Jo. For reference, January 1, 1900 has a Julian Day Number Jo 2415021. Note: The L...] is a floor function which indicates rounding a value "down" to the nearest integer. e.g. [5.85] = 5. (d) Calculate the lunar phase. With the elapsed number of days, we can determine the percent illumination of the moon, L. L = (sin (7AJ mod T)? 1 indicates a full moon, i.e. 100% illumination, where 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started