Practical 4: For- and While- Loops, If-statements
Command Sequence Controls
Indenting
Indenting
Note that the above code has indents under each of for and if statement
Indenting makes code more readable, as you can see the logical structure which becomes especially important when you have several for/if statements in one M-file. While working on this practical, make sure that you follow this formatting convention.
Exercise: Counter variable > Reconsider the above example without indenting. Which is easier to read?
|
![]() |
Example: % determine the number of elements in allNumbers bigger count = 0; end |