MAE 08 Lecture Notes - Lecture 15: Infinite Loop, While Loop, Matlab

46 views2 pages

Document Summary

Combined use of for/while loops with if/switch statements. While loop is a conditional loop, it is used when the number of repetitions is not known ahead of time. If it is logically true, the actions are executed (similar to if statement) Then condition is evaluated again, and if it still true, execute action again. The repetition will stop when the condition is false. Condition has to change within the action block of the while loop. The condition must become false to avoid an infinite loop. It is important to identify the loop breaker in the action block. If infinite loop occurs by error, use ctrl-c" to exit the loop. Write a script input_positive. m to ask user to input a positive integer and make sure that the user has done it correctly. Action: repeat asking until both conditions are satisfied. Matlab have built in is " that test whether or not something is true.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents