module m2-1 2 electrical engineering -...

10
TUTORIAL 1 VECTOR ANALYSIS AUGUST 4, 2016 Module M2-1 Electrical Engineering 1 Topics Review of vectors (with Matlab) Examples In-class exercises 2 After this tutorial, you will be able to 3 understand the concepts of the unit vector, rectangular coordinate system, and vector field add vectors, subtract vectors, and multiple a vector by a scale compute the magnitude of a vector, the dot product, and the cross product write a simple Matlab program to compute vector algebra Notation Vector or or Scalar Vector and scalar quantities Vector is a quantity that has both magnitude and direction We usually represent a vector by a bold font, or a font with an arrow or a hat on top A A 4 ~ A b A Use an arrow for an arbitrary vector Use a hat to emphasize that a vector has length (magnitude) 1 In this class, we will use these 2 notations

Upload: others

Post on 06-Nov-2019

30 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Module M2-1 2 Electrical Engineering - KMUTTwebstaff.kmutt.ac.th/~watcharapan.suw/class/M2-1/tut/M2-1-Tut1-c.pdf · Electrical Engineering 1 Topics Review of vectors (with Matlab)

T U T O R I A L 1 V E C T O R A N A L Y S I S A U G U S T 4 , 2 0 1 6

Module M2-1 Electrical Engineering

1

Topics

�  Review of vectors (with Matlab) �  Examples �  In-class exercises

2

After this tutorial, you will be able to 3

�  understand the concepts of the unit vector, rectangular coordinate system, and vector field

�  add vectors, subtract vectors, and multiple a vector by a scale

�  compute the magnitude of a vector, the dot product, and the cross product

�  write a simple Matlab program to compute vector algebra

Notation

Vector or or

Scalar

Vector and scalar quantities

�  Vector is a quantity that has both magnitude and direction

�  We usually represent a vector by a bold font, or a font with an arrow or a hat on top

A

A

4

~A bA

Use an arrow for an arbitrary vector

Use a hat to emphasize that a vector has length (magnitude) 1

In this class, we will use these 2 notations

Page 2: Module M2-1 2 Electrical Engineering - KMUTTwebstaff.kmutt.ac.th/~watcharapan.suw/class/M2-1/tut/M2-1-Tut1-c.pdf · Electrical Engineering 1 Topics Review of vectors (with Matlab)

The Cartesian coordinate system

�  The direction of the axes is determined by the right-hand rule

�  Each point in the space is represented by a triple (x, y, z)

x

y

z

x

y

z

5

The vector from one point to another point

�  The vector from point to point is given by or

http://www.colorado.edu/geography/ gcraft/notes/coordsys/coordsys_f.html

(x2, y2, z2)(x1, y1, z1)

6

~A = (x2 � x1)bi+ (y2 � y1)bj+ (z2 � z1)bk

~A =⇥x2 � x1 y2 � y1 z2 � z1

Concept question 7

ข้อใดคือเวกเตอร์ในสองมิต ิที่เริ่มต้นจากจุด (-2,1) และสิ้นสุด ที่จุด (3,-5)  

ก.  

ข.  

ค. ไม่มีข้อใดถูก 

(ส่วนหนึ่งของข้อสอบปลายภาคปีการศึกษา 1/2556) 

5bi� 6bj

6bi� 5bj

Vector operation in Matlab

�  Matlab represents a vector by >> A = [1 2 3]

�  For a vector � The magnitude (or length) of is given by

� Matlab command for the magnitude >> norm(A)

8

~A =bi+ 2bj+ 3bk

~A =⇥A

x

Ay

Az

⇤= A

x

bi+Ay

bj+Az

bk

|~A| =qA2

x

+A2y

+A2z

~A

Page 3: Module M2-1 2 Electrical Engineering - KMUTTwebstaff.kmutt.ac.th/~watcharapan.suw/class/M2-1/tut/M2-1-Tut1-c.pdf · Electrical Engineering 1 Topics Review of vectors (with Matlab)

A unit vector 9

�  A unit vector is a vector of magnitude 1

�  Example: is a unit vector because

~M =1p6bi+ 2p

6bj� 1p

6bk

| ~M| =

s✓1p6

◆2

+

✓2p6

◆2

+

✓� 1p

6

◆2

=

r1

6+

4

6+

1

6

= 1

A unit vector in the direction of vector .

10

�  is the vector that points to the same direction as and has the magnitude of 1

~B

~B

length 1

baBA unit vector in the direction of vector . ~B

~B

Example 1

baB

A unit vector in the direction of vector .

~B

length 1

~B

Example 2

(continued) 11

�  In general for vector , the unit vector in the direction of is

�  Example: The unit vector in the direction of is

~B =⇥B

x

By

Bz

⇤= B

x

bi+By

bj+Bz

bk~B

baB

=~Bq

B2x

+B2y

+B2z

=~B

|~B|

x

y

-3

0

-1

~B = �3bj

~B = �3bj

baB =~B

|~B|=

�3bj3

= �bj

baB = �bj

Dot product

�  For vector and vector

�  The dot product is a scalar that equals

�  Matlab command >> dot(A,B)

12

~A =⇥A

x

Ay

Az

⇤= A

x

bi+Ay

bj+Az

bk~B =

⇥B

x

By

Bz

⇤= B

x

bi+By

bj+Bz

bk~A • ~B

~A • ~B = Ax

Bx

+Ay

By

+Az

Bz

= |~A||~B| cos ✓

~A ~Bthe angle between and

Page 4: Module M2-1 2 Electrical Engineering - KMUTTwebstaff.kmutt.ac.th/~watcharapan.suw/class/M2-1/tut/M2-1-Tut1-c.pdf · Electrical Engineering 1 Topics Review of vectors (with Matlab)

Cross product

�  The cross product is a vector that equals

�  Matlab command >> cross(A,B)

13

~A⇥ ~B

~A⇥ ~B =

������

bi bj bkA

x

Ay

Az

Bx

By

Bz

������

= (Ay

Bz

�Az

By

)bi+ (Az

Bx

�Ax

Bz

)bj+ (Ax

By

�Ay

Bx

)bk

determinant

The determinant of a 3-by-3 matrix is easy to compute by hand

14

�  Multiply the individual items �  Put the negative signs for the upward terms �  Combine the terms

������

bi bj bk1 2 34 5 6

������

�(4)(2)bk�(5)(3)bi�(6)(1)bj

(2)(6)bi

(3)(4)bj

bi bj1 24 5

=

������

bi bj bk1 2 34 5 6

������(1)(5)bk

= �8bk� 15bi� 6bj +5bk+ 12bj+ 12bi

= �3bi+ 6bj� 3bk

Magnitude and direction of .

�  The magnitude is �  The direction is orthogonal to both and and in

the direction of the thumb (right-hand rule)

15

~A⇥ ~B

~A⇥ ~B

~A

~B

|~A⇥ ~B| = |~A||~B| sin ✓

~A ~B

~A ~Bthe angle between and

right hand

Example: cross product

The cross product of the two vectors and is shown in blue

16

~A = 2bi+bj+ 0bk~B = 1bi+ 2bj+ 0bk

~C = 0bi+ 0bj+ 3bk

Page 5: Module M2-1 2 Electrical Engineering - KMUTTwebstaff.kmutt.ac.th/~watcharapan.suw/class/M2-1/tut/M2-1-Tut1-c.pdf · Electrical Engineering 1 Topics Review of vectors (with Matlab)

Concept question 17

มีขนาดและทิศใด เมื่อ และ   

ก. ขนาด 1 ชี้ตามแกน -z  

ข. ขนาด 2 ชี้ตามแกน +z 

ค. ไม่มีข้อใดถูก  

(ส่วนหนึ่งของข้อสอบปลายภาคปีการศึกษา 1/2556) 

~A⇥ ~B ~B =⇥0 �1 0

⇤~A =

⇥2 0 0

Example: 2D Cartesian coordinate system

�  Let vectors , , and equal

�  Question 1: Draw these vectors in the same diagram

18

~A ~B

~A =⇥3 �2

⇤ ~C =⇥�2 0

⇤~B =

⇥1 3

⇤~C

Solution (picture) to question 1 19

−5 −4 −3 −2 −1 0 1 2 3 4 5−5

−4

−3

−2

−1

0

1

2

3

4

5

x

y

~A =⇥3 �2

~C =⇥�2 0

~B =⇥1 3

Example: 2D (cont.)

�  Question 2: Find in Matlab and draw in paper the vector sums and

�  Solution (Matlab): >> clear all % clear all variables >> A = [ 3 -2]; >> B = [ 1 3]; >> C = [-2 0];

20

~A+ ~B ~A+ ~B+ ~C

>> A+B ans = 4 1 >> A+B+C ans = 2 1

Page 6: Module M2-1 2 Electrical Engineering - KMUTTwebstaff.kmutt.ac.th/~watcharapan.suw/class/M2-1/tut/M2-1-Tut1-c.pdf · Electrical Engineering 1 Topics Review of vectors (with Matlab)

Solution (picture): .

triangular law parallelogram law

21

~A+ ~B =⇥4 1

−4 −3 −2 −1 0 1 2 3 4−4

−3

−2

−1

0

1

2

3

4

x

y

~A

~B

~A+ ~B

−4 −3 −2 −1 0 1 2 3 4−4

−3

−2

−1

0

1

2

3

4

x

y

~A

~B~A+ ~B

Solution (picture): .

triangular law parallelogram law

22

~A+ ~B+ ~C =⇥2 1

−4 −3 −2 −1 0 1 2 3 4−4

−3

−2

−1

0

1

2

3

4

x

y ~A+ ~B

~A+ ~B+ ~C

~C

−4 −3 −2 −1 0 1 2 3 4−4

−3

−2

−1

0

1

2

3

4

x

y ~A+ ~B

~C~A+ ~B+ ~C

Example: 2D (cont.)

�  Question 3: Find and draw vector differences , , and

�  Solution (Matlab): >> A-B ans = 2 -5 >> B-A ans = -2 5 >> A-B-C ans = 4 -5

23

~A� ~B� ~C~A� ~B ~B� ~A

Solution (picture) 24

−6 −4 −2 0 2 4 6

−6

−4

−2

0

2

4

6

x

y

~B� ~A

~A� ~B~A� ~B� ~C

Page 7: Module M2-1 2 Electrical Engineering - KMUTTwebstaff.kmutt.ac.th/~watcharapan.suw/class/M2-1/tut/M2-1-Tut1-c.pdf · Electrical Engineering 1 Topics Review of vectors (with Matlab)

Example: 2D (cont.)

�  Question 4: Find and draw scalar multiplications of vectors , , and

�  Solution (Matlab): >> 2*A ans = 6 -4 >> -3*B ans = -3 -9 >> C/1.5 ans =

-1.3333 0

25

2~A �3~A ~C/1.5

Solution (picture): .

26

2~A =⇥6 �4

−8 −6 −4 −2 0 2 4 6 8−8

−6

−4

−2

0

2

4

6

8

x

y

2~A

~A

Solution (picture): .

27

�3~B =⇥�3 �9

−10 −8 −6 −4 −2 0 2 4 6 8 10

−10

−8

−6

−4

−2

0

2

4

6

8

10

x

y

�3~B

~B

Solution (picture): .

28

~C

1.5=

⇥� 4

3 0⇤

−3 −2 −1 0 1 2 3−3

−2

−1

0

1

2

3

xy

~C

~C

1.5

Page 8: Module M2-1 2 Electrical Engineering - KMUTTwebstaff.kmutt.ac.th/~watcharapan.suw/class/M2-1/tut/M2-1-Tut1-c.pdf · Electrical Engineering 1 Topics Review of vectors (with Matlab)

Example: 2D (cont.)

�  Question 5: Find the dot product:

�  Solution: >> dot(A, B) ans = -3

29

~A • ~B

Example: 2D (cont.)

�  Question 6: Find and draw the cross product

�  Solution: >> cross([A 0], [B 0]) ans =

0 0 11

Append zero to the z-component, so we have a 3D vector needed for computing a cross product

30

~A⇥ ~B

Solution (picture) 31

−10−5

05

10

−10−5

05

10

−10

−5

0

5

10

xy

z

~A⇥ ~B

~A ~B

Vector field is a type of functions 32

�  Definition: A vector field in two dimensions is a function that assign to each point a two-dimensional vector

�  To picture a vector field, we draw the arrow representing the vector starting at the point

(x, y)

(x, y)

. (x, y)

~F(x, y)

~F(x, y)

~F(x, y)

~F

ปริมาณเวกเตอร์ที่พิกัดนั้น 

ตำแหน่ง หรือพิกัด 

Page 9: Module M2-1 2 Electrical Engineering - KMUTTwebstaff.kmutt.ac.th/~watcharapan.suw/class/M2-1/tut/M2-1-Tut1-c.pdf · Electrical Engineering 1 Topics Review of vectors (with Matlab)

Example of a vector field in 2D 33

�  Example: A vector field in 2D is defined by Describe the field by sketching some of the vectors

�  Solution: see next page

~F(x, y) = �y

bi+ x

bj

~F(x, y)

34

Given that , so

0

y

x

1 2

3 continuing this way, we draw a number of representative vectors

3

~F(x, y) = �y

bi+ x

bj1 ~F(1, 0) = �(0)bi+ (1)bj = bj

2 ~F(0, 1) = �(1)bi+ (0)bj = �bi

A vector field in 3D 35

�  Definition: A vector field in three dimensions is a function that assign to each point a three-dimensional vector

(x, y, z)

~F(x, y, z)

~F

ปริมาณเวกเตอร์ที่พิกัดนั้น 

ตำแหน่ง หรือพิกัด 

Example of a vector field in 3D 36

�  Example: A vector field is given by Evaluate at position (2, 4, 3)

�  Answer:

~S

~S(x, y, z) =4

(x� 1)2 + (y � 2)2 + (z + 1)2

h(x� 1)bi+ (y � 2)bj+ (z + 1)bk

i

~S

~S(2, 4, 3) =4n

(2� 1)bi+ (4� 2)bj+ (3 + 1)bko

(2� 1)2 + (4� 2)2 + (3 + 1)2

=4

21bi+ 8

21bj+ 16

21bk

= 0.19bi+ 0.38bj+ 0.76bk

put x = 2

y = 4

z = 3

Page 10: Module M2-1 2 Electrical Engineering - KMUTTwebstaff.kmutt.ac.th/~watcharapan.suw/class/M2-1/tut/M2-1-Tut1-c.pdf · Electrical Engineering 1 Topics Review of vectors (with Matlab)

37

(continued) Matlab plot of is below

−100

10

−10

0

10

−10

0

10

xy

z

~S(x, y, z) Summary 38

�  Vector arithmetic ¡  vectors in Matlab ¡  magnitude, unit vector ¡  sum, difference, scalar multiplication ¡  dot product, cross product ¡  vector field

39

In-class exercise

Homework 1(a) 40

Given the vectors and , find the magnitude of

~M =bi� 2bj+ 3bk ~N = 2bi� bkbk� 2~N+ ~M