MATLAB Programming/Loops and Branches

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Program Flow[edit | edit source]

The idea of program flow is simple. However, implementing and using flow techniques effectively takes practice. MATLAB flow control is almost identical to flow control in C. There is a tremendous amount of text on the subject of flow in C. If you do a little homework in about an hour you can know all you need to from one of numerous C tutorials. To be good at flow control all you have to do is practice.

Here are a few concepts that you can practice using flow control to implement:

  • Calculate compounding interest using a while loop (don't cheat by using the algebraic form).
  • Create a moving average filter using a for loop
  • Make a counter that keeps track of keystrokes:How many times a typist hits a certain letter.