{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

EGR_102_Lab_10A_Iterative_Programming_II

# EGR_102_Lab_10A_Iterative_Programming_II - Iterative...

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

EGR 102 Lab 10A 1 Iterative Programming II EGR 102 Lab 10A 2 Structured Programming Two types of statements that allow programs to take non-sequential paths: Conditional Programming (Selection) Branches the flow based on a decision Iterative Programming (Repetition) Loops the flow to allow statements to be repeated

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

View Full Document
EGR 102 Lab 10A 3 Iterative Programming Loops perform operations repetitively. The number of iterations is dependant on the type of loop. EGR 102 Lab 10A 4 Iterative Programming Two types of MATLAB loop structures: for structure Loop ends after a specified number of repetitions while structure Loop ends when a logical condition is satisfied This type of programming only used inside user-defined functions and scripts (M-files)
EGR 102 Lab 10A 5 while Structure Repeats the same set of commands as long as a logical condition remains true General syntax of while loop: while condition statements end condition is a logical expression that is either true or false statements are the commands to be repeated as long as the condition is TRUE EGR 102 Lab 10A 6 while Structure General syntax of while loop: while condition statements end The variable in the condition expression: 1. Must be defined before the loop 2. Must be recalculated within the loop Unlike the for loop, user does not know how many times the while loop will repeat

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

View Full Document
EGR 102 Lab 10A 7 while Structure Simple Examples: x = 8 while x > 0 x = x – 3 end
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern