To write:
The script for the following switch statement give below first generates a random force value. Then, prints a message regarding what type of wind that force represents, using a switch statement. And rewrite this switch statement as one nested if-else statement that accomplishes exactly the same thing. Use else and/or elseif clauses.
ranforce = randi([0, 12]);
switch ranforce
case 0
disp('There is no wind')
case {1, 2, 3, 4, 5, 6}
disp('There is a breeze')
case {7, 8, 9}
disp('This is a gale')
case {10, 11}
disp('It is a storm')
case 12
disp('Hello, Hurricane!')
end
In which, the Beaufort Wind Scale is used to characterize the strength of winds. The scale uses integer values and goes from a force of 0, which is no wind, up to 12, which is a hurricane.
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
MATLAB: A Practical Introduction to Programming and Problem Solving
- How many different signals can be sent, when three flags are used, if two of the 9 flags are missing?arrow_forwardAlthough Pythagoras preceded William Shakespeare by 2,000 years, the philosophy of the Pythagoreans is mentioned in Shakespears The Merchant of Venice. Here is a quote from that play: Thou almost makst me waver in my faith, To hold opinion will Pythagoras, That souls of animals infuse themselves Into the trunks of men. Research the Pythagoreans. What were the main beliefs held by their society? What part of the philosophy of the Pythagoreans was Shakespeare referring to specifically with this quote? What present-day religions share a similar belief? Write a paragraph or two about your findings.arrow_forwardA Bitter Dispute With the publication of Ars Magna, a dispute intensified between Jerome Cardan and another mathematician named Niceolo Fontana, otherwise known as Tartaglia. What was the dispute, and how did it arise? In your opinion, who was at fault? Write a paragraph or two about your findings.arrow_forward
- Trigonometry (MindTap Course List)TrigonometryISBN:9781305652224Author:Charles P. McKeague, Mark D. TurnerPublisher:Cengage LearningAlgebra: Structure And Method, Book 1AlgebraISBN:9780395977224Author:Richard G. Brown, Mary P. Dolciani, Robert H. Sorgenfrey, William L. ColePublisher:McDougal LittellCollege Algebra (MindTap Course List)AlgebraISBN:9781305652231Author:R. David Gustafson, Jeff HughesPublisher:Cengage Learning