Question: Write a Matlab function that converts calendar months (input as numbers, 1-12) to seasons (output as numbers, 1-4). Months 12 and 1-2 are season
Write a Matlab function that converts calendar months (input as numbers, 1-12) to seasons (output as numbers, 1-4). Months 12 and 1-2 are season 1 [winter], 3-5 are season 2 [spring], 6-8 are season 3 [summer], 9-11 season 4 [fall]. Have the function exit with an error (Matlab error()) if the input month is not an integer, or is not between 1 and 12. Include help text to tell users what the function does. Check the function with a valid input (such as 7) and an invalid input (such as 0) Hint: You can use an if...else...then statement, to set the value of the output season to 1-4 depending on the month, and to signal an error if the input month was not an integer or not between 1 and 12. It's also possible to use a switch...case statement to do the same thing.
Step by Step Solution
There are 3 Steps involved in it
Certainly Below is a MATLAB function that fulfills the specified requirem... View full answer
Get step-by-step solutions from verified subject matter experts
