Skip to main content

11.16) Increment Statement


We have seen a few examples of the term "x=x+1".

Remember that Matlab executes the right hand side and then assigns the answer to the variable on the left had side.

So "x=x+1" is a way of incrementing x by 1. Matlab first calculates "x+1" and then assigns this new value to "x".

It is useful in loops and other flow control statements when we want to count an occurrence of an event.