Additional Variables: Special Matrices
Additional Variables: Special Matrices
MATLAB has several commands that will produce special matrices. Such commands include
ones() (matrix of 1s)
zeros() (matrix of 0s)
eye() (identity)
inv() (inverse)
det() (result is not a matrix) (determinant)
>> ones(3)
ans =
1 1 1
1 1 1
1 1 1
>> zeros(3,2)
ans =
0 0
0 0
0 0
Additional Variables
For most applications MATLAB variables will be assigned to numeric and/or string values.
The
numeric values will usually be real or complex. With the addition of the Symbolic toolbox,
variables can also be declared as symbolic variables. This section will briefly describe some
aspects of working with complex and string variables.
Complex Numbers
MATLAB has fully integrated complex arithmetic. All variables are considered to be
complex
and basic arithmetic operations perform correctly on both the real- and imaginary-part of
complex numbers. The imaginary unit is automatically assigned to i and j. A complex
number
is entered as follows:
>> z = 1 + 2i
z =
1.0000 + 2.0000i
>> w = 1 – 2j
w =
1.0000 - 2.0000i