<< Chapter < Page | Chapter >> Page > |
The number
is predefined in MATLAB and stored in the two variable locations denoted byand. This double definition comes from the preference of mathematicians for using
and the preference of engineers for using
(with
denoting electrical current).andare variables, and their contents may be changed. If you type, then this is the value forandno longer contains
. Type into restore the original value. Note the way a complex variable is displayed. If you type, you should get the answer
i
The same value will be displayed for. Try it. Using, you can now
enter complex variables. For example, enterand.
Asis a variable, you have to use the multiplication sign. Otherwise, you
will get an error message. MATLAB does not differentiate (except in storage)between a real and a complex variable. Therefore variables may be added, subtracted, multiplied, or even divided. For example, type in. The real and imaginary parts ofare both divided by.
MATLAB just treats the real variableas a complex variable with a zero
imaginary part. A complex variable that happens to have a zero imaginarypart is treated like a real variable. Subtractfromand display the
result.
z1
MATLAB contains several built-in functions to manipulate complex numbers. For example,extracts the real part of the complex number. Type
z
to get the result
Similarly,extracts the imaginary part of the complex number. The
functionsandcompute the absolute value (magnitude) of
the complex numberand its angle (in radians). For example, type
z
The last command shows how to get back the original complex number from its magnitude and angle. This is clarified in Chapter 1: Complex Numbers.
Another useful function,, returns the complex conjugate of
the complex number. Ifwhereandare real, thenis
equal to. Verify this for several complex numbers by using the function.
conj (z)
Notification Switch
Would you like to follow the 'A first course in electrical and computer engineering' conversation and receive update notifications?