name=value
. The name can be any charactersequence.
With the exception of the first character it may also contain
numbers. The value is any number or expression.
>> x=24+3i x = 24+3i
Some variables are predefined (like pi
). The last previous
result of a calculation is stored in the variable ans
.
All variables are displayed by the command who
. Single
variables can be deleted by entering clear variable
.
It is possible to define variables whose value is a function.
In this case the function's name must be preceded by the character $
to suppress evaluation. These variables can be used like the function they stand for.
For example, who dislikes the builtin function realpart(x)
's name
can shorten it to the Matlab-version:
>> real=$realpart $realpart >> real(24+3i) ans = 24