<img src="https://d5nxst8fruw4z.cloudfront.net/atrk.gif?account=iA1Pi1a8Dy00ym" style="display:none" height="1" width="1" alt="" />
Dismiss
Skip Navigation

3.4: Basic Complex and Matrix Operations

Difficulty Level: At Grade Created by: CK-12
Turn In

Complex numbers

m-file 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=2ejπ simply enter

z1 = 7 + j

and

z2 = 2*exp(j*pi)

Table 2 gives an overview of the basic functions for manipulating complex numbers, where z is a complex number.

Manipulating complex numbers.
m-file
Re(z)
real(z)
Im(z)
imag(z)
mag(z)
abs(z)
(z)
angle(z)
z
conj(z)

Operations on Matrices

In addition to scalars, m-file environments can operate on matrices. Some common matrix operations are shown in Table 3; in this table,

M

and

N

are matrices.

Common matrix operations.
Operation m-file
MN
M*N
M1
inv(M)
MT
M' 
det(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=(1111). Then

A^2

will return AA=(2222), while

A.^2

will return (12121212)=(1111).

Example 5

Given a vector

x

,

compute a vector

y

having elements y(n)=1sin(x(n)). This can be easily be done with the command

y=1./sin(x)

Note that using

/

in place of

./

would result in the (common) error "Matrix dimensions must agree".

Notes/Highlights Having trouble? Report an issue.

Color Highlighted Text Notes
Please to create your own Highlights / Notes
Show More

Image Attributions

Show Hide Details
Files can only be attached to the latest version of section
Please wait...
Please wait...
Image Detail
Sizes: Medium | Original
 
CK.ENG.ENG.SE.1.Engineering-Matlab.3.4
Here