Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write it in MatLab: 1. The Lunar Phase Calculator. In this problem, you will construct a script that returns the lunar phase for a user-
Write it in 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. 1 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres a MATLAB script that follows the requirements laid out in the problem statement matlab function lunarphasecalculator Take 3 separate command win...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