O'Reilly logo

MATLAB Control Systems Engineering by César Pérez López

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 2

image

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required