3.4: Basic Complex and Matrix Operations
Complex numbers
mfile environments have excellent support for complex numbers. The imaginary unit is denoted by
i
or
(as preferred in Electrical Engineering)
j
.
To create complex variables
z1 = 7 + j
and
z2 = 2*exp(j*pi)
Table 2 gives an overview of the basic functions for manipulating complex numbers, where
mfile  


real(z) 

imag(z) 

abs(z) 

angle(z) 

conj(z) 
Operations on Matrices
In addition to scalars, mfile environments can operate on matrices. Some common matrix operations are shown in Table 3; in this table,
M
and
N
are matrices.
Operation  mfile 


M*N 

inv(M) 

M' 

det(M) 
Some useful facts:
 The functions
length
and
size
are used to find the dimensions of vectors and matrices, respectively.
 Operations can also be performed on each element of a vector or matrix by proceeding the operator by ".", e.g
.*
,
.^
and
./
.
Example 4
Let
A^2
will return
A.^2
will return
Example 5
Given a vector
x
,
compute a vector
y
having elements
y=1./sin(x)
Note that using
/
in place of
./
would result in the (common) error "Matrix dimensions must agree".
Image Attributions
To add resources, you must be the owner of the section. Click Customize to make your own copy.