Docsity

MATLAB Data Types & Plotting: Complex Numbers, Strings, Arrays, Plots, Slides of Computer Science

Partial preview of the text

Download MATLAB Data Types & Plotting: Complex Numbers, Strings, Arrays, Plots and more Slides Computer Science in PDF only on Docsity!

Chapter 6 Additional Data

Types and plot Types

Chun-Ming Tsai

Contents

  • Complex data
  • String functions
  • Multidimensional Arrays
  • Additional Data Types
  • Additional Two-Dimensional Plots
  • Three-Dimensional Plots

6.1 Complex Data

  • Complex numbers are numbers with both a real and an

imaginary component.

P

a + bi

real axis

imaginary axis

b

a

P a + bi

real axis

imaginary axis

z



a

b

z a b

b z

a z

c a bi z

1

2 2

tan

sin

cos

= āˆ’

= +

=

=

= + = 









  • If complex numbers c 1 and c 2 are defined as c 1 = a 1 + b 1 i ,

and c 2 = a 2 + b 2 i , then the addition, subtraction, multiplication, and division of c 1 and c 2 are defined as:

i a b

b a a b

a b

a a bb

c

c

c c a a bb a b b a i

c c a a b b i

c c a a b b i

2 2

2 2

1 2 1 2 2 2

2 2

1 2 1 2

2

1

1 2 1 2 1 2 1 2 1 2

1 2 1 2 1 2

1 2 1 2 1 2

  • Using complex numbers with relational

operators

  • It is possible to compare two complex numbers with the == relational operator - To see if they equal to each other.
  • To compare them with the ~= operator
    • To see if they are not equal to each other.
  • However, comparisons with the >, <, >=, or <= operators do not produce the expected results. - Compare with real parts
  • Compare with the magnitudes of c 1 and c

See Table 6.1 (page 266)

  • Example 6.1 The Quadratic Equation

(revisited)

  • Page 270
  • If both the real and imaginary parts of the

function are of interest, then the user has

several choices.

  • Alternatively, the real part of the function

can be plotted versus the imaginary part.