Skip to main content

11.1) Flow Control


Flow control means specifying pathways through a program so that modules can be repeated or skipped. It is a very powerful and useful feature of many high-level programming languages.
Matlab provides several constructs which enable the programmer to specify alternative actions depending on the outcome of a logical test, or to repeat statements within loops.

  • if...elseif...else..end
  • switch...case...otherwise
  • for...end
  • while...end
  • try...catch

In the following examples, you will notice that text indentation is used to improve readability.