Write it in MatLab: 1. The Lunar Phase Calculator. In this problem, you will construct a script
Fantastic news! We've Found the answer you've been seeking!
Question:
Write it in MatLab:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
Heres a MATLAB script that follows the requirements laid out in the problem statement matlab function lunarphasecalculator Take 3 separate command win... View the full answer
Related Book For
Integrated Accounting
ISBN: 978-1285462721
8th edition
Authors: Dale A. Klooster, Warren Allen, Glenn Owen
Posted Date:
Students also viewed these programming questions
-
Write a user-defined MATLAB function that calculates the determinant of a 3 3 matrix by using the formula: For the function name and arguments, use d3 = det3by3 (A), where the input argument A is...
-
Write a MATLAB program tointegrate /2 cos(cos.x) dr
-
Write a user-defined MATLAB function that determines the angle that forms by the intersection of two lines. For the function name and arguments, use th=anglines (A,B,C). The input arguments to the...
-
1. What responsibility does an organization have to ensure that its suppliers and business partners behave ethically? To whom is this responsibility owed? 2. How can an organization monitor the...
-
1. Comment on International Cosmetics policies on the basis of as reported earnings. 2. Is management correct in stating that by translating their financial reports into dollars they automatically...
-
A childs swing (a pendulum) has only one natural frequency, f1, yet it can be driven or pushed smoothly at frequencies of f1/2, f1/3, and 2f1. How is this possible?
-
On December 10, 2017, Robin Franchises, a U.S. company, received a purchase order from a U.K. customer for delivery of merchandise on January 15, 2018. The price of the merchandise is 8,000,000,...
-
Pryce Company owns equipment that cost $65,000 when purchased on January 1, 2011. It has been depreciated using the straight-line method based on estimated salvage value of $5,000 and an estimated...
-
This question deals with determining risk guidelines for a bond portfolio. The key underlying objective is to recognize all the diverse dimensions of risk in a portfolio and how they can be...
-
Gold Sporting Equipment (GSE) is in the process of preparing its budget for the third quarter of 2010. The budgeting staff has gathered the following data: 1. Account balances as of June 30: 3. Sales...
-
Delph Company uses a job - order costing system and has two manufacturing departments Molding and Fabrication. The company provided the following estimates at the beginning of the year: Molding...
-
You run a simulator twice with exactly the same input, but the output of the two runs is slightly different. For example, a water mole fraction is reported as \(0.98014 \mathrm{E}-02\) and as...
-
a. It is very important for a leader to stick to his/her guns. b. It is not very important for a leader to stick to his/her guns. _____ After you have circled the letter, indicate how certain you are...
-
The U.S. residential construction contracting industry is composed of about 160,000 firms (single-location companies and units of multilocation companies) that renovate and build residential...
-
Shane Company, which produces and sells a small digital clock, bases its pricing strategy on a 30 percent markup on total cost. Based on annual production costs for 15,000 units of product,...
-
Mendez Inc. experienced the following accounting events during its 2011 accounting period. 1. Paid cash to settle an account payable. 2. Collected a cash advance for services that will be provided...
-
Please help! Text Book: Life Span Development 18th edition by John W. Santrock Respond to this week's discussion prompt . Helping adolescents develop their identity can cause stress as teenagers want...
-
You work as an operations consultant for a textile company. Your client has a well-established distribution system in the US market. The company has hundreds of stores and four distribution centers....
-
Describe the process for correcting a general journal entry.
-
If the statement is true, write T in the space provided. If the statement is false, write F in the space provided. 1. The depreciation rate for the double-declining-balance method is twice the...
-
What information is contained on the Cash Payments Journal report?
-
Question: Sports Graphics, Inc. imports "Chill" brand coolers from Taiwan. Chill coolers have an outer shell of vinyl, with handles and pockets, and an inner layer of insulation. In a recent lawsuit,...
-
Question: In a recent WTO case, several nations claimed that American laws concerning shrimp fishing were unfair and illegal. The case demonstrated a conflict between two important values. What were...
-
Question: Flyby Knight (FK) contracts to sell 12 helicopters to Air Nigeria, for $8 million each. Payment is to be made by letter of credit, issued by the Bank of Nigeria, confirmed by Citibank in...
Study smarter with the SolutionInn App