1 / 18

MATLAB Trigonometry, Complex Numbers and Array Operations

MATLAB Trigonometry, Complex Numbers and Array Operations. Basic Trigonometry. Basic Trigonometric Expressions in MATLAB. sin( alpha ) Sine of alpha cos( alpha ) Cosine of alpha tan( alpha ) Tangent of alpha

pegeen
Download Presentation

MATLAB Trigonometry, Complex Numbers and Array Operations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 .π/2 and π/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 π (quadrants I and II). • atan(z) Arctangent or inverse tangent of z. Returns an angle between .π/2 and π/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 -π and π (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 = √(-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 = Re[z]; y = Im[z]

  9. Complex Numbers - Rectangular Representatiton • A general complex number can be formed in three ways: >> z = 1 + j*2 z = 1.0000+ 2.0000i >> z = 1 + 2j z = 1.0000+ 2.0000i >> z = complex(1,2) z = 1.0000 + 2.0000i

  10. Complex Numbers - Rectangular Representatiton >> z = 3 + 4j z = 3.0000+ 4.0000i >> x = real(z) x = 3 >> 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 >> z = 3 + 4j; >> r = abs(z) r = 5 >> 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 elementof 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 ≤ π. 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.1π, 0.2π, . . . , π 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. x1is 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, >> x=[0 .1*pi .2*pi .3*pi .4*pi .5*pi .6*pi .7*pi .8*pi .9*pi pi] By a function, >>y=sin(x) Vector Addressing A vector element is addressed in Matlab with an integer index (also called a subscript) enclosedin parentheses. For example, to access the third element of x and the fifth element of y: >> x(3) ans = 0.6283 >> y(5) ans = 0.9511

  17. Colon Notation Addresses a block of elements The format for colon notation is: (start:increment:end) 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: (start:end)

  18. Colon Notation Examples 1:5 means “start with 1 and count up to 5.” >> x(1:5) ans = 0 0.3142 0.6283 0.9425 1.2566 7:end means “start with 7 and count up to the end of the vector.” >> x(7:end) ans = 1.8850 2.1991 2.5133 2.8274 3.1416 3:-1:1 means “start with 3 and count down to 1.” >> y(3:-1:1) ans = 0.5878 0.3090 0 2:2:7 means “start with 2, count up by 2, and stop at 7.” >> x(2:2:7) ans = 0.3142 0.9425 1.5708

More Related