Upload
stephanie-atkins
View
234
Download
0
Embed Size (px)
Citation preview
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)
Scalar product
AB = |A||B|cos = ABcos Equivalent definition
AB = AxBx +AyBy +AzBz Scalar projection
BA B
proj AB
����������������������������
����������������������������
example_101
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
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
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
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 ��������������������������������������������������������
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.
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
cos
sin
x
y
z 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)
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
-2-1
01
2
-2
-1
0
1
20
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.
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
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.
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
Conversion of variables between Cartesian and spherical coordinate systems
2 2 2
1
1
cos
tan
r x y z
zr
yx
sin cos
sin sin
cos
x r
y r
z 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)