MATLAB. functions. Overview

Similar documents
Metas.UncLib. Michael Wollensack und Marko Zeier. Metas Seminar Ein Messunsicherheitsrechner für Fortgeschrittene

THE COMPLEX EXPONENTIAL FUNCTION

Week 13 Trigonometric Form of Complex Numbers

COMPLEX NUMBERS. a bi c di a c b d i. a bi c di a c b d i For instance, 1 i 4 7i i 5 6i

Final Exam Review: VBA

Georgia Department of Education Kathy Cox, State Superintendent of Schools 7/19/2005 All Rights Reserved 1

C Programming Language

Chapter 5 Functions. Introducing Functions

South Carolina College- and Career-Ready (SCCCR) Pre-Calculus

The KmPlot Handbook. Klaus-Dieter Möller Philip Rodrigues David Saxton

User Guide.

Complex Algebra. What is the identity, the number such that it times any number leaves that number alone?

Techniques of Integration

WORKBOOK. MATH 30. PRE-CALCULUS MATHEMATICS.

Estimated Pre Calculus Pacing Timeline

Introduction to Complex Numbers in Physics/Engineering

MAC Learning Objectives. Module 10. Polar Form of Complex Numbers. There are two major topics in this module:

The OptQuest Engine Java and.net Developer's Guilde

MATLAB Commands and Functions

PURSUITS IN MATHEMATICS often produce elementary functions as solutions that need to be

Lecture Notes on Polynomials

ab = c a If the coefficients a,b and c are real then either α and β are real or α and β are complex conjugates

The Mathematics Diagnostic Test

ANALYTICAL METHODS FOR ENGINEERS

How To Use Matlab

Mathematics. ( : Focus on free Education) (Chapter 5) (Complex Numbers and Quadratic Equations) (Class XI)

The Exponential Form of a Complex Number

Notes and questions to aid A-level Mathematics revision

Section 9.1 Vectors in Two Dimensions

Semester 2, Unit 4: Activity 21

Euler s Formula Math 220

Trigonometric Functions and Triangles

Algebra. Exponents. Absolute Value. Simplify each of the following as much as possible. 2x y x + y y. xxx 3. x x x xx x. 1. Evaluate 5 and 123

Trigonometric Functions: The Unit Circle

Introduction to MATLAB

Approximating functions by Taylor Polynomials.

Triangle Trigonometry and Circles

Differentiation and Integration

1 TRIGONOMETRY. 1.0 Introduction. 1.1 Sum and product formulae. Objectives

PROBLEM SET. Practice Problems for Exam #1. Math 1352, Fall Oct. 1, 2004 ANSWERS

ex) What is the component form of the vector shown in the picture above?

2 Session Two - Complex Numbers and Vectors

Trigonometry Hard Problems

Graphs of Polar Equations

Find the length of the arc on a circle of radius r intercepted by a central angle θ. Round to two decimal places.

Exam 1 Sample Question SOLUTIONS. y = 2x

Computing Euler angles from a rotation matrix

A few words about imaginary numbers (and electronics) Mark Cohen

Parameters and Expressions

x(x + 5) x 2 25 (x + 5)(x 5) = x 6(x 4) x ( x 4) + 3

5.3 SOLVING TRIGONOMETRIC EQUATIONS. Copyright Cengage Learning. All rights reserved.

MATH 381 HOMEWORK 2 SOLUTIONS

Trigonometric Functions and Equations

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language

GRE Prep: Precalculus

Evaluating trigonometric functions

Introduction to MS Excel

Course outline, MA 113, Spring 2014 Part A, Functions and limits Functions, domain and ranges, A Review (9 problems)

Trigonometry Review with the Unit Circle: All the trig. you ll ever need to know in Calculus

10 Polar Coordinates, Parametric Equations

Mathematics Placement Examination (MPE)

Review of Matlab for Differential Equations. Lia Vas

DEFINITION A complex number is a matrix of the form. x y. , y x

Dear Accelerated Pre-Calculus Student:

Precalculus REVERSE CORRELATION. Content Expectations for. Precalculus. Michigan CONTENT EXPECTATIONS FOR PRECALCULUS CHAPTER/LESSON TITLES

10.3. The Exponential Form of a Complex Number. Introduction. Prerequisites. Learning Outcomes

Math Placement Test Practice Problems

Friday, January 29, :15 a.m. to 12:15 p.m., only

Math, Trigonometry and Vectors. Geometry. Trig Definitions. sin(θ) = opp hyp. cos(θ) = adj hyp. tan(θ) = opp adj. Here's a familiar image.

Grade 6 Mathematics Assessment. Eligible Texas Essential Knowledge and Skills

ALGEBRA 2/TRIGONOMETRY

SAT Subject Test Practice Test II: Math Level II Time 60 minutes, 50 Questions

C. Complex Numbers. 1. Complex arithmetic.

SAT Subject Math Level 2 Facts & Formulas

FX 115 MS Training guide. FX 115 MS Calculator. Applicable activities. Quick Reference Guide (inside the calculator cover)

Algebra and Geometry Review (61 topics, no due date)

Sample Test Questions

88 CHAPTER 2. VECTOR FUNCTIONS. . First, we need to compute T (s). a By definition, r (s) T (s) = 1 a sin s a. sin s a, cos s a

A very minimal introduction to TikZ

COMPLEX NUMBERS AND DIFFERENTIAL EQUATIONS

Some Comments on the Derivative of a Vector with applications to angular momentum and curvature. E. L. Lady (October 18, 2000)

2.2 Magic with complex exponentials

COMPLEX NUMBERS AND SERIES. Contents

Version 1.0. General Certificate of Education (A-level) January Mathematics MPC4. (Specification 6360) Pure Core 4. Final.

Introduction to Complex Fourier Series

2.2 Separable Equations

Signal Processing First Lab 01: Introduction to MATLAB. 3. Learn a little about advanced programming techniques for MATLAB, i.e., vectorization.

UNIVERSITY OF NEWCASTLE UPON TYNE

PYTHAGOREAN TRIPLES KEITH CONRAD

MATLAB Basics MATLAB numbers and numeric formats

Core Maths C2. Revision Notes

A First Course in Electrical and Computer Engineering. By: Louis Scharf

ALGEBRA 2/TRIGONOMETRY

Unit 6 Trigonometric Identities, Equations, and Applications

Solutions to Exercises, Section 5.1

New Higher-Proposed Order-Combined Approach. Block 1. Lines 1.1 App. Vectors 1.4 EF. Quadratics 1.1 RC. Polynomials 1.1 RC

Mathematics I, II and III (9465, 9470, and 9475)

Solving Equations and Inequalities

Algebra 2: Themes for the Big Final Exam

Higher Education Math Placement

Transcription:

MATLAB Functions 3 Overview In this chapter we start studying the many, many, mathematical functions that are included in MATLAB. Some time will be spent introducing complex variables and how MATLAB handles them. Later we will learn how to write custom (user written) functions which are a special form of m-file. Two dimensional plotting functions will be introduced. We will also explore programming constructs for flow control (if-else-elseif code blocks) and looping (for loop etc.). Next data analysis functions will be investigated, which includes sample statistics and histogram plotting functions. Chapter 3: Overview 3 1

Mathematical Functions Common Math Functions Table 3.1: Common math functions Function Description Function Description abs(x) sqrt(x) round(x) nearest integer fix(x) nearest integer floor(x) x nearest integer ceil(x) nearest integer toward toward sign(x) rem(x,y) the remainder 1, x < 0 of x y 0, x = 0 1, x > 0 x exp(x) log(x) natural log e x lnx log10(x) log base 10 log 10 x Examples:» x = [-5.5 5.5];» round(x) ans = -6 6» fix(x) ans = -5 5» floor(x) ans = -6 5» ceil(x) Chapter 3: Mathematical Functions 3

ans = -5 6» sign(x) ans = -1 1» rem(3,6) ans = 5 Trigonometric and Hyperbolic Functions Unlike pocket calculators, the trigonometric functions always assume the input argument is in radians The inverse trigonometric functions produce outputs that are in radians Table 3.: Trigonometric functions Function Description Function Description sin(x) tan(x) acos(x) atan(y, x) sin( x) tan( x) cos(x) asin(x) atan(x) cos 1 ( x) tan 1 ( x) the inverse tangent of y x including the correct quadrant cos( x) sin 1 ( x) Examples: A simple verification that sin ( x) + cos ( x) = 1 Chapter 3: Mathematical Functions 3 3

» x = 0:pi/10:pi;» [x' sin(x)' cos(x)' (sin(x).^+cos(x).^)'] ans = 0 0 1.0000 1.0000 0.314 0.3090 0.9511 1.0000 0.683 0.5878 0.8090 1.0000 0.945 0.8090 0.5878 1.0000 1.566 0.9511 0.3090 1.0000 1.5708 1.0000 0.0000 1.0000 1.8850 0.9511-0.3090 1.0000.1991 0.8090-0.5878 1.0000.5133 0.5878-0.8090 1.0000.874 0.3090-0.9511 1.0000 3.1416 0.0000-1.0000 1.0000 Parametric plotting: Verify that by plotting sinθ versus cosθ for 0 θ πwe obtain a circle» theta = 0:*pi/100:*pi; % Span 0 to pi with 100 pts» plot(cos(theta),sin(theta)); axis('square')» title('parametric Plotting','fontsize',18)» ylabel('y - axis','fontsize',14)» xlabel('x - axis','fontsize',14)» figure()» hold Current plot held» plot(cos(5*theta).*cos(theta),... cos(5*theta).*sin(theta)); % A five-leaved rose Chapter 3: Mathematical Functions 3 4

1 0.8 Parametric Plotting Circle 0.6 0.4 Rose 0. y - axis 0-0. -0.4-0.6-0.8-1 -1-0.8-0.6-0.4-0. 0 0. 0.4 0.6 0.8 1 x - axis The trig functions are what you would expect, except the features of atan(y,x) may be unfamiliar y y 4 x x φ 1 = 0.4636 4 φ =.0344 Chapter 3: Mathematical Functions 3 5

» [atan(/4) atan(,4)] ans = 0.4636 0.4636 % the same» [atan(-4/-) atan(-4,-)] ans = 1.1071 -.0344 % different; why? e x The hyperbolic functions are defined in terms of There are no special concerns in the use of these functions except that atanh requires an argument that must not exceed an absolute value of one Complex Number Functions Table 3.3: Hyperbolic functions Function Description Function Description sinh(x) tanh(x) acosh(x) e x e x ----------------- cosh(x) asinh(x) e x e x ------------------ ln( x + x + 1 ) e x + e x ln( x+ x 1) atanh(x) Before discussing these functions we first review a few facts about complex variable theory In electrical engineering complex numbers appear frequently A complex number is an ordered pair of real numbers 1 e x e x ----------------- 1 + x ln -----------, x 1 1 x 1.Tom M. Apostle, Mathematical Analysis, second edition, Addison Wesley, p. 15, 1974. Chapter 3: Mathematical Functions 3 6

denoted The first number, a, is called the real part, while the second number, b, is called the imaginary part For algebraic manipulation purposes we write ( ab, ) = a + ib = a+ jb where i = j = 1 ; electrical engineers typically use j since i is often used to denote current Note: ( ab, ) 1 1 = 1 j j = 1 For complex numbers we define/calculate = a 1 + jb 1 and z = a + jb + z = ( a 1 + a ) + jb ( 1 + b ) (sum) z = ( a 1 a ) + jb ( 1 b ) (difference) z = ( a 1 a b 1 b ) + ja ( 1 b + b 1 a ) (product) ---- z = ( a 1 a + b 1 b ) ja ( 1 b b 1 a ) --------------------------------------------------------------------------- a + b (quotient) = a 1 + b 1 (magnitude) = tan 1 ( b 1 a 1 ) (angle) = a 1 jb 1 (complex conjugate) MATLAB is consistent with all of the above, starting with the fact that i and j are predefined to be 1 Chapter 3: Mathematical Functions 3 7

The rectangular form of a complex number is as defined above, The corresponding polar form is z = ( ab, ) = a+ jb z = r θ where r = a + b and θ = tan 1 ( b a) Imaginary Axis Complex Plane b r θ a Real Axis MATLAB has five basic complex functions, but in reality most all of MATLAB s functions accept complex arguments and deal with them correctly Function conj(x) real(x) imag(x) Table 3.4: Basic complex functions Description Computes the conjugate of which is z = a jb Extracts the real part of which is real( z) = a Extracts the imaginary part of z = a+ jb which is imag( z) z = a+ jb z = a + jb = b Chapter 3: Mathematical Functions 3 8

Function Table 3.4: Basic complex functions Description angle(x) computes the angle of z = a+ jb using atan which is atan(imag(z),real(z)) Euler s Formula: A special mathematical result of, special importance to electrical engineers, is the fact that Turning (3.1) around yields It also follows that where e jb = cosb+ jsinb sinθ cosθ = = e jθ e jθ --------------------- j e jθ e jθ + --------------------- z = a + jb = re jθ (3.1) (3.) (3.3) (3.4) r = a + b, θ = tan 1b ā -, a = rcosθ, b = rsinθ Chapter 3: Mathematical Functions 3 9

Some examples:» z1 = +j*4; z = -5+j*7;» [z1 z] ans =.0000 + 4.0000i -5.0000 + 7.0000i» [real(z1) imag(z1) abs(z1) angle(z1)] ans =.0000 4.0000 4.471 1.1071» [conj(z1) conj(z)] ans =.0000-4.0000i -5.0000-7.0000i» [z1+z z1-z z1*z z1/z] ans = -3.0000 +11.0000i 7.0000-3.0000i -38.0000-6.0000i 0.43-0.4595i Polar Plots: When dealing with complex numbers we often deal with the polar form. The plot command which directly plots vectors of magnitude and angle is polar(theta,r) This function is also useful for general plotting As an example the equation of a cardioid in polar form, with parameter a, is r = a1 ( + cosθ), 0 θ π» theta = 0:*pi/100:*pi; % Span 0 to pi with 100 pts» r = 1+cos(theta);» polar(theta,r) Chapter 3: Mathematical Functions 3 10

Polar Plot 10 90 60 1.5 150 1 30 0.5 180 0 10 330 40 300 70 Chapter 3: Mathematical Functions 3 11