matlab - lecture 4

22
ENE 206 Matlab 4 Coordinate systems

Upload: chanon-tonmai

Post on 14-Apr-2016

258 views

Category:

Documents


0 download

DESCRIPTION

sdfgsdfs

TRANSCRIPT

Page 1: Matlab - Lecture 4

ENE 206Matlab 4

Coordinate systems

Page 2: Matlab - Lecture 4

Vector and scalar quantities

Vector

scalar A

ˆA or A or

A

Page 3: Matlab - Lecture 4

Vectors - Magnitude and direction

1. Cartesian coordinate system (x-, y-, z-)

Page 4: Matlab - Lecture 4

Vector operation in Matlab

x y zx y zA A a A a A a

Cartesian coordinate system

Example

A = 1ax + 2ay + 3az

>> A = [1 2 3]

Find the magnitude of A>> norm(A)or >> abs(A)

Page 5: Matlab - Lecture 4

Scalar product

AB = |A||B|cos = ABcos Equivalent definition

AB = AxBx +AyBy +AzBz

Scalar projection

BA Bproj A

B

example_101

Page 6: Matlab - Lecture 4

Cross product

A x B = |A||B|sin = ABsin Equivalent definition

Matlab command is >> cross(A,B)

ˆ ˆ ˆx y z

x y z

x y z

a a a

A B A A A

B B B

ˆ ˆ ˆy z z y x z x x z y x y y x zA B A B a A B A B a A B A B a

Page 7: Matlab - Lecture 4

Cross product (cont.)

The cross product of the two vectors A = 2ax + 1ay + 0az and B = 1ax + 2ay + 0az is shown. The vector product of the two vectors A and B is equal to C = 0ax + 0ay + 3az

.

example_102

Page 8: Matlab - Lecture 4

Scalar triple product

A (B x C)=B (C x A) = C (A x B)

>> dot(A, cross(B,C))

Page 9: Matlab - Lecture 4

Vector triple product

A x (B x C)=B(A C) -C(A B)

>> cross(A, cross(B,C))

Page 10: Matlab - Lecture 4

Volume defined by three vectors originating at a point

v = area of the base x height v = (|A x B|)(C an)

where an = (A x B)/|A x B|

A = [3 0 0];B = [0 2 0];C = [0 2 4];deltav = C(A x B)

example_103

Page 11: Matlab - Lecture 4

Cylindrical coordinate system (, , z)

orthogonal point (, , z) = a radial distance (m) = the angle measured from

x axis to the projection of the radial line onto x-y plane

z = a distance z (m)

zzA A a A a A a

Page 12: Matlab - Lecture 4

Transformation of a vector in cylindrical coordinates to one in Cartesian coordinates

Ax = Aax

Ay = Aay

Az = Aaz

where A is in cylindrical coordinates and assumed constant.

Page 13: Matlab - Lecture 4

Dot products of unit vectors in Cartesian and cylindrical coordinate systems

cos -sin 0

sin cos 0

0 0 1

a a ˆzaˆxaˆya

ˆza

Page 14: Matlab - Lecture 4

cossin

xyz z

2 2

1tan

x y

yx

z z

Conversion of variables between Cartesian and cylindrical coordinates

A conversion from P(x,y,z) to P(ρ,, z)

A conversion from P(ρ,, z) to P(x,y,z)

Matlab command

[ph,rh,z] = cart2pol(x,y,z)Matlab command

[x,y,z] = pol2cart(ph,rh,z)

Page 15: Matlab - Lecture 4

The transformation of a vector A = 3ax + 2ay + 4az in Cartesian coordinates into a vector in cylindrical coordinates. The unit vectors of the two coordinate systems are indicated.

figure_112

Page 16: Matlab - Lecture 4

-2-1

01

2

-2-1

0

120

0.2

0.4

0.6

0.8

1

Cylinder creation in Matlab

>> [x,y,z] = cylinder(r,n); >> surf (x,y,z)where r = radius

n = number of pts along the circumference.

Page 17: Matlab - Lecture 4

Spherical coordinate system (, , )

rrA A a A a A a

orthogonal point (r,, ) r = a radial distance from the

origin to the point (m) = the angle measured from

the positive z-axis (0 ) = an azimuthal angle,

measured from x-axis (0 2)

figure_113

Page 18: Matlab - Lecture 4
Page 19: Matlab - Lecture 4

Transformation of a vector in spherical coordinates to one in Cartesian coordinates

Ax = Aax

Ay = Aay

Az = Aaz

where A is in spherical coordinates and assumed constant.

Page 20: Matlab - Lecture 4

Dot products of unit vectors in Cartesian and spherical coordinates

sincos coscos -sin

sinsin cossin cos

cos -sin 0

ˆra a aˆxaˆya

ˆza

Page 21: Matlab - Lecture 4

Conversion of variables between Cartesian and spherical coordinate systems

2 2 2

1

1

cos

tan

r x y z

zr

yx

sin cossin sincos

x ry rz r

A conversion from P(x,y,z) to P(r,, )

A conversion from P(r,, ) to P(x,y,z)

Matlab command

[th,phi,r] = cart2sph(x,y,z)Matlab command

[x,y,z] = sph2cart(th,phi,r)

Page 22: Matlab - Lecture 4

Convert the Cartesian coordinate point P(3, 5, 9) to its equivalent point in cylindrical and spherical

coordinates.