EXPERIMENT #1 VECTOR ANALYSIS: DOT AND

advertisement
EXPERIMENT #1
VECTOR ANALYSIS: DOT AND CROSS
PRODUCT OF A VECTOR FIELD
Objectives
The objective of Experiment #1 is to provide you with an introduction to calculating and
plotting scalar and vector field using MATLAB. In this experiment you will generate
surface/vector of a dot and cross product of a vector field.
Lecture Review
Electromagnetic (EM) is a branch of physics or electrical engineering in which electric
and magnetic phenomena are studied. Vector analysis is a mathematical tool with which
electromagnetic (EM) concept are most conveniently expressed and best comprehended.
A quantity is said to be scalar if it has only magnitude. Quantity such as time, mass,
distance, temperature, entropy, electric potential, and population are scalars. A quantity is
called a vector if has magnitude and direction such as velocity, force, displacement and
electric field intensity. There are four types of vector algebra:
1.
Vectors may add and subtracted.
A ± B = (Axax + Ayay + Azaz) ± (Bxax + Byay + Bzaz)
= (Ax ± Bx) ax + (Ay ± By) ay + (Az ± Bz) az
2.
The associative, distributive, and commutative laws apply.
A + (B+C) = (A + B) + C
k ( A+B) = kA + kB
( k1+ k2 ) A = k1 A + k2B
A+B=B+A
3.
The dot product of two vectors is, by definition,
A . B = |A| |B| Cos θAB
A . B = Ax Bx + AyBy + AzBz
A . A = ‫׀‬A‫׀‬2 = A2x + A2y + A2z
4.
The cross product of two vectors is,
A x B = |A| |B| sin θAB an
A x B = AyBx + Ax By @ Ax By - AyBx
% cross product with (x,y,z)
A x B = (AyBz –Az By)ax + (AzBx –Ax Bz) ay + (AxBy –Ay Bx) az
Where θ is the smaller angle between A and B and an is a unit vector normal to
the plane.
5.
Dot and cross product for two vector can be apply using MATLAB simulation.
MATLAB can visualizing the scalar and vector field the generated surface of the
dot and cross product.
6.
Useful MATLAB command cover plotting dot and cross product of a vector field
show in Table 1.
Matlab Command
Definition
quiver
To draw arrows normal to the underlying surface with
length scaled by exponential slope at each point
quiver3
For 3D quiver plots. Display the vectors (Nx,Ny,Nz)at
each points (x,y,z)
surf
To generate surface plots ( to fill the patches – the space
between lines) / to interpolate
Table 1
Example 1.1
Using MATLAB simulation,
1. Plot the vector field of A = 2 ax for 0≤x<1.5 and 0<y<1.5.
2. Plot the vector field of B = sin (xy) ax + e-(x
for 0<x<1.5 and 0<y<1.5.
2
2
+ y )
3. Plot a 3D scalar field of a dot product A . B
4. Plot a 3D vector field of a cross product A X B
ay
Solution Example 1.1
1)
% Dot and Cross Product
>> x=0:0.25:1.5;
>> y=0:0.25:1.5;
>> [xx,yy]=meshgrid(x,y);
>> Ax=2*ones(size(xx));
>> Ay=zeros(size(yy));
>> figure;quiver(xx,yy,Ax,Ay,0.5);
>> xlabel('x');ylabel('y');
>> title('Vector Field : {\bf A} = 2{\bf x }');
OR
% Dot and Cross Product
>>x=0:0.25:1.5;
>>y=0:0.25:1.5;
>> [xx,yy]=meshgrid(x,y);
>>figure;quiver(xx,yy,2*ones(size(xx)),zeros(size(yy)),0.5);
>>xlabel('x');ylabel('y');
>>title('Vector Field : {\bf A} = 2{\bf x }');
The Result is;
Vector Field : A = 2 x
1.6
1.4
1.2
1
y
0.8
0.6
0.4
0.2
0
-0.2
0
0.2
0.4
0.6
0.8
1
x
1.2
1.4
1.6
1.8
2)
>> % Plot vector B
>> x=0:0.25:1.5;
>>y=0:0.25:1.5;
>>[xx,yy]=meshgrid(x,y);
>> Bx=sin(xx.*yy);(size(xx));
>> By=exp(-(xx.^2 + yy.^2));(size(yy));
>> figure;quiver(xx,yy,Bx,By);
>> xlabel('x'); ylabel('y');
>> title('Vector Field : {\bf B}= sin xy{\bf x} + e^{-(x^2 + y^2)}{\bf y}');
2
2
Vector Field : B= sin xy x + e-(x + y ) y
1.6
1.4
1.2
y
1
0.8
0.6
0.4
0.2
0
-0.2
0
0.2
0.4
0.6
0.8
x
1
1.2
1.4
1.6
1.8
3)
>> % A dot B (A . B)
>> A_dot_B= Ax.*Bx + Ay.*By;
>> figure;surf(x,y,A_dot_B);
>> shading interp;
>> xlabel('x');ylabel('y');zlabel('\bf A \cdot B ');
>> title ('Scalar Field: {\bf A \cdot B}');
% the answer for the dot product of A and B, can be calculated using Matlab.
% but we have to put a value fot the variable x and y
>> x=1;
>> y=1;
>> A = [ 2
0
>> B = [sin(x.*y)
>> D=dot(A,B)
% answer
D=
1.6829
0];
exp(-(x.^2 + y.^2))
0];
4)
>> % A Cross B (A X B)
>> % A x B = (AyBz –Az By)ax + (AzBx –Ax Bz) ay + (AxBy –Ay Bx) az
>> % In this case, z = 0; so ax = 0 and ay = 0
>> % but, the equation A = 2 ax + 0 ay , so there is no imaginary part
>> % A x B = (AxBy –Ay Bx) az
>>x=0:0.25:1.5
>>y=0:0.25:1.5
>>z=0;
>> [xx,yy,zz]=meshgrid(x,y,z);
>> A_cross_B_z= Ax.*By;
>> Ax=2*ones(size(xx));
>> By=exp(-(xx.^2 + yy.^2));(size(yy));
>> figure;quiver3(xx,yy,zz,0,0,A_cross_B_z,2);
>> xlabel('x');ylabel('y');zlabel('z');
>> title('Vector Field : {\bf A \times B}');
OR
>>x=0:0.25:1.5
>>y=0:0.25:1.5
>> [xx,yy,zz]=meshgrid(x,y,z);
>> A_cross_B_z= Ax.*By;
>> Ax=2*ones(size(xx));
>> By=exp(-(xx.^2 + yy.^2));(size(yy));
>> figure;quiver3(xx,yy,zeros(size(zz)),0,0,A_cross_B_z,2);
>> xlabel('x');ylabel('y');zlabel('z');
>> title('Vector Field : {\bf A \times B}');
The Result is:
Vector Field : A  B
0.8
z
0.6
0.4
0.2
0
2
2
1
1.5
1
0
y
0.5
-1
0
-0.5
x
% the answer for the cross product of A and B, can be calculated using Matlab.
% but we have to put a value for the variable x and
>> x=1;
>> y=1;
>> A = [ 2
0
0];
>> B = [sin(x.*y)
exp(-(x.^2 + y.^2))
>>C=cross(A,B)
% answer
C=
0
0
0.2707
0]
Exercise 1
1. Plot the following vector using MATLAB:
i)
P = 2x2 ax + 2 ay
ii)
Q = cos xy ax + cos y2 ay for 0 < x <3 and 0 < y<3
iii)
Plot 3D scalar field of a dot product P.Q
iv)
Plot a 3D vector field of a cross product P x Q
for 0 < x <1.5 and 0 < y<1.5
Exercise 2
1. Given vector A (4 3 0) B (1 0 2) C (0 2 1) find
i)
(A x B) x C
ii)
A x (B x C)
iii)
A.BxC
iv)
AxB. C
2. Three field quantities vector are given by
P = 2 ax - az
Q = 2 ax – ay + 2az
R = 2 ax – 3ay + az
Determine:
i)
ii)
(P+Q) x (P-Q)
Q.R x P
iii)
P.Q x R
Download