08.07.2015 Views

Introduction to MATLAB 7 for Engineers Chapter 1 An ... - FET

Introduction to MATLAB 7 for Engineers Chapter 1 An ... - FET

Introduction to MATLAB 7 for Engineers Chapter 1 An ... - FET

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A simple example of a while loop isx = 5;k = 0;while x < 25k = k + 1;y(k) = 3*x;x = 2*x-1;end1-52The loop variable x is initially assigned the value 5, and itkeeps this value until the statement x = 2*x - 1 isencountered the first time. Its value then changes <strong>to</strong> 9.Be<strong>for</strong>e each pass through the loop, x is checked <strong>to</strong> see ifits value is less than 25. If so, the pass is made. If not, theloop is skipped.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!