{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

EGR_102_Lab_10A_Iterative_Programming_II

EGR_102_Lab_10A_Iterative_Programming_II - Iterative...

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
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)
Image of page 2
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
Image of page 3

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern