MATLAB Trigonometry, Complex Numbers and Array Operations - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

MATLAB Trigonometry, Complex Numbers and Array Operations

Description:

asin(z) Arcsine or inverse sine of z, where z must be between .1 and 1. Returns ... Returns an angle between -p and p (all quadrants), depending on the signs of ... – PowerPoint PPT presentation

Number of Views:145
Avg rating:3.0/5.0
Slides: 19
Provided by: IKU
Category:

less

Transcript and Presenter's Notes

Title: MATLAB Trigonometry, Complex Numbers and Array Operations


1
MATLABTrigonometry, Complex Numbers and Array
Operations
2
Basic Trigonometry
3
Basic Trigonometric Expressions in MATLAB
  • sin(alpha) Sine of alpha
  • cos(alpha) Cosine of alpha
  • tan(alpha) Tangent of alpha
  • asin(z) Arcsine or inverse sine of z, where z
    must be between .1 and 1. Returns an angle
    between .p/2 and p/2 (quadrants I and IV).
  • acos(z) Arccosine or inverse cosine of z, where z
    must be between .1 and 1. Returns an angle
    between 0 and p (quadrants I and II).
  • atan(z) Arctangent or inverse tangent of z.
    Returns an angle between .p/2 and p/2 (quadrants
    I and IV).
  • atan2(y,x) Four quadrant arctangent or inverse
    tangent, where x and y are the coordinates in the
    plane shown in the .gure above. Returns an angle
    between -p and p (all quadrants), depending on
    the signs of x and y.

4
Hyperbolic Functions
  • The hyperbolic functions are functions of the
    natural exponential function ex, where e is the
    base of the natural logarithms, which is
    approximately e 2.71828182845904. The inverse
    hyperbolic functions are functions of the natural
    logarithm function, ln x.
  • The curve y cosh x is called a catenary (from
    the Latin word meaning chain). A chain or rope,
    suspended from its ends, forms a curve that is
    part of a catenary.

5
Basic Hyperbolic Expressions in MATLAB
6
Complex Numbers
  • Imaginary number The most fundamental new
    concept in the study of complex numbers is the
    imaginary number j. This imaginary number is
    defined to be the square root of -1
  • j v(-1)
  • j2 -1

7
Complex Numbers - Rectangular Representatiton
8
Complex Numbers - Rectangular Representatiton
  • Rectangular Representation A complex number z
    consists of the real part x and the imaginary
    part y and is expressed as
  • z x jy
  • where
  • x Rez y Imz

9
Complex Numbers - Rectangular Representatiton
  • A general complex number can be formed in three
    ways
  • gtgt z 1 j2
  • z
  • 1.0000 2.0000i
  • gtgt z 1 2j
  • z
  • 1.0000 2.0000i
  • gtgt z complex(1,2)
  • z
  • 1.0000 2.0000i

10
Complex Numbers - Rectangular Representatiton
  • gtgt z 3 4j
  • z
  • 3.0000 4.0000i
  • gtgt x real(z)
  • x
  • 3
  • gtgt y imag(z)
  • y
  • 4

11
Polar Representation
  • Defining the radius r and the angle ? of the
    complex number z can be represented in polar form
    and written as
  • z r cos ? jr sin ?
  • or, in shortened notation
  • z r ?

12
Polar Representation
  • gtgt z 3 4j
  • gtgt r abs(z)
  • r
  • 5
  • gtgt theta angle(z)
  • theta
  • 0.9273
  • theta (180/pi)angle(z)
  • theta
  • 53.1301

13
Polar Representation
14
Arrays and Array Operations
  • Scalars Variables that represent single numbers,
    as considered to this point. Note that complex
    numbers are scalars, even though they have two
    components, the real part and the imaginary part.
  • Arrays Variables that represent more than one
    number. Each number is called an element of the
    array. Rather than than performing the same
    operation on one number at a time, array
    operations allow operating on multiple numbers at
    once.
  • Row and Column Arrays A row of numbers (called a
    row vector) or a column of numbers (called a
    column vector).
  • Two-Dimensional Arrays A two-dimensional table
    of numbers, called a matrix.
  • Array Indexing or Addressing Indicates the
    location of an element in the array.

15
Vector Arrays
  • Consider computing y sin(x) for 0 x p. It
    is impossible to compute y values for all values
    of x, since there are an infinite number of
    values, so we will choose a finite number of x
    values.
  • Consider computing
  • y sin(x), where x 0, 0.1p, 0.2p, . . . , p
  • You can form a list, or array of the values of
    x, and then using a calculator you can compute
    the corresponding values of y, forming a second
    array y.

x and y are ordered lists of numbers, i.e., the
first value or element of y is associated with
the first value or element of x. Elements can be
denoted by subscripts, e.g. x1 is the first
element in x, y5 is the fifth element in y. The
subscript is the index, address, or location of
the element in the array.
16
Vector Creation
  • By an explicit list,
  • gtgt x0 .1pi .2pi .3pi .4pi .5pi .6pi .7pi
    .8pi .9pi pi
  • By a function,
  • gtgtysin(x)
  • Vector Addressing
  • A vector element is addressed in Matlab with an
    integer index (also called a subscript) enclosed
    in parentheses. For example, to access the third
    element of x and the ?fth element of y
  • gtgt x(3)
  • ans
  • 0.6283
  • gtgt y(5)
  • ans
  • 0.9511

17
Colon Notation
  • Addresses a block of elements The format for
    colon notation is
  • (startincrementend)
  • where start is the starting index, increment is
    the amount to add to each successive index, and
    end is the ending index, where start, increment,
    and end must be integers. The increment can be
    negative, but negative indices are not allowed to
    be generated. If the increment is to be 1, a
    shortened form of the notation may be used
  • (startend)

18
Colon Notation Examples
  • 15 means start with 1 and count up to 5.
  • gtgt x(15)
  • ans
  • 0 0.3142 0.6283 0.9425 1.2566
  • 7end means start with 7 and count up to the
    end of the vector.
  • gtgt x(7end)
  • ans
  • 1.8850 2.1991 2.5133 2.8274 3.1416
  • 3-11 means start with 3 and count down to 1.
  • gtgt y(3-11)
  • ans
  • 0.5878 0.3090 0
  • 227 means start with 2, count up by 2, and
    stop at 7.
  • gtgt x(227)
  • ans
  • 0.3142 0.9425 1.5708
Write a Comment
User Comments (0)
About PowerShow.com