Skip to main content

3.2) Declaring Variables (cont'd)


Note also that when we typed:

[matlab]
>> c=2^10
[/matlab]

or

[matlab]
d=4+(2*6)
[/matlab]

Matlab calculated the right hand side and assigned it to the variable.

[matlab]
c=1024
[/matlab]

and

[matlab]
d=16
[/matlab]

This is because Matlab executes commands much like a calculator. Now try the following:

[matlab]
>> a=2
>> b=3;
[/matlab]

See how Matlab reported that it had set "a" to 3 but it didn't tell you about assigning 3 to "b".

The semi-colon (;) tells Matlab to suppress output to the screen.