Skip to main content
Library homepage
 
Engineering LibreTexts

2.8: Complex Numbers

  • Page ID
    84384
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    By Carey A. Smith

    The imaginary unit number is i.

    i = sqrt(-1) or i^2 = -1
    In engineering, j is often used instead of i for the imaginary unit number.
    In MATLAB, you can use either i or j.
    Therefore, i and j should not be used as variable names. Instead, use ii or jj or another letter.
    In MATLAB, 2*i can be written as 2i, 3*i as 3i, etc. Try this.
    A complex number has both a real part and an imaginary part.

    Example \(\PageIndex{1}\) Complex Numbers 1

    a = 2 + i
    b = 1 - 4i
    c = -2 + 3j

    Solution

    Add example text here.

    Exercise \(\PageIndex{1}\) Complex Numbers real and imag parts, length

    % (1 pt) Write a MATLAB m-file script that does the following:
    % (1 pt) Define this complex number:
    z1 = (2 + 3i)
    % (2 pts) Separate the real and imaginary parts like this:
    z1_real = real(z1)
    z1_imag = imag(z1)

    % (1 pt) Compute the conjugate of z1 with this line of code:
    z2 = conj(z1) % This changes the sign on the imaginary part
    % (1 pt) Compute:
    z1*conj(z1) % Note that this = square of the real part + square of the imaginary part

    % (1 pt) Compute the length of this vector:
    z1_length = sqrt(z1*conj(z1))

    Answer

    z2 = conj(z1) = 2 - 3i

    z1*conj(z1) = 13

    z1_length = 3.6056

    Exercise \(\PageIndex{2}\) Plot a Complex Number, version 1

    % (3 pts) A complex number can be plotted by letting zx = real(z1) and zy = imag(z1)
    % Plot this complex number with these lines of code:
    figure;
    plot(z1_real,z1_imag,'*')
    grid on % Draw x & y grid lines
    xlim([-1,4]) % Set the minimum and maximum x values
    ylim([-1,4]) % Set the minimum and maximum y values

    Answer

    Add texts here. Do not delete this text first.

    Example \(\PageIndex{2}\) Plot a Line to a Complex Number

    Draw a line from (0,0) to the point with the following code:
    hold on % Keep whats been plotted and add to it
    plot([0,z1_real],[0,z1_imag])
    % [0,z1_real] = x coordinates of start and and end of the line
    % [0,z1_imag] = y coordinates of start and and end of the line

    Solution

    Add example text here.


    This page titled 2.8: Complex Numbers is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Carey Smith.

    • Was this article helpful?