CHAPTER 2
Variables, Numbers, Operators and Functions
Variables
MATLAB does not require a command to declare variables. A variable is created simply by directly allocating a value to it. For example:
>> v = 3v =3
The variable v will take the value 3 and using a new mapping will not change its value. Once the variable is declared, we can use it in calculations.
>> v ^ 3ans =27>> v + 5ans =8
The value assigned to a variable remains fixed until it is explicitly changed or if the current MATLAB session is closed.
If we now write:
>> v = 3 + 7v =10
then the variable v has the value 10 from now on, as shown in the following calculation:
>> v ^ 4ans ...
Get MATLAB Control Systems Engineering now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.