# Ch5_11 - 11 Section 5.11 Loops for and while Not needed as...

This preview shows pages 1–7. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 11 Section 5.11: Loops - for and while Not needed as much as with other languages, because of MatLab's ability to do matrix math loops are useful when running multiple cases However, Section 5.11: Loops -- for and while Previous Next The for loop 22 for variable = starting value : increment : ending value e.g. for k=1:1:kmax MatLab functions max, min, and sort using fprintf with vectors is convenient you have to be careful to get proper result MatLab uses a `end' to indicate end of for loop statements C++ used { }'s to enclose the loop statements Section 5.11: Loops -- for and while Previous Next Executing the for loop example: maxmin.m 33 maxmin.m is in the Chapter5 Examples folder Section 5.11: Loops -- for and while Previous Next The while loop 44 Start of while loop similar to C++ if criteria is true, loop is executed MatLab functions std and mean MatLab uses an `end' to indicate end of while loop statements C++ used { }'s to enclose the loop statements When the program reaches the end statement, it: returns to the while statement checks the criteria to determine if it should continue loop Section 5.11: Loops -- for and while Previous Next Executing the while loop example: stdmean.m 55 stdmean.m is in the Chapter5 Examples folder Section 5.11: Loops -- for and while Previous Next 66 End of Slide Show for Section 5.11 MatLab examples done in this section maxmin.m stdmean.m This is a good time to work on Exercise 5.11 Section 5.11: Loops -- for and while Previous Next 77 End of Slide Show for Section 5.11 MatLab examples done in this section maxmin.m stdmean.m This is a good time to work on Exercise 5.11 Section 5.11: Loops -- for and while Previous Next ...
View Full Document

{[ snackBarMessage ]}

### Page1 / 7

Ch5_11 - 11 Section 5.11 Loops for and while Not needed as...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online