To change a variable:
To change a variable, the other assignment statement can be used that assigns the value of a different expression to it. Consider, for illustration, the following sequence of statements:
>> mynum = 3
mynum =
3
>> mynum = 4 + 2
mynum =
6
>> mynum = mynum + 1
mynum =
7
In the initial assignment statement, the 3 is assigned to the variable mynum. In later the assignment statement, mynum is changed to have the value of the expression 4 + 2, or 6. At the third assignment statement, mynum is changed all over again, to the result of the expression mynum +1. As at that time mynum had the value 6, the value of the expression be 6+1, or 7.