Computational Electromagnetics-: Abstract
Computational Electromagnetics-: Abstract
Computational Electromagnetics-: Abstract
ABSTRACT:
To know the various applications in the MATLAB and implementing
the operations such as Gradient ,divergence and curl of vector and scalar
using MATLAB .
PROGRAM:
1. Calculate gradient curl divergence
close all %closes all opened MATLAB figures
clear all %clear all the data in variable
clc %clear the command window syms x y
z %declares variable
u1=[x^2*y*z 0 x*z]; %variable u1 is assigned with (x^2yz)ax+(xz)az
d=curl(u1,[x,y,z]) %variables d is assigned with the curl
u2=[x^2*y*z 0 x*z]; %U2 variable is assigned with another vector
function
d1=divergence(u2,[x y z])%variable d1 is assigned with another vector
function U2.
2. Gradient
3.
close all %closes all opened MATLAB figures
clear all %clear all the data in variable clc
%clear the command window
4.
close all
clear all clc
[x,y] = meshgrid(-8:0.2:8);
U1 = x.*y; surf(x,y,U1);
contour(x,y,U1);
xlabel('x') ylabel('y')
zlabel('z') OUTPUT:
1.
2.
3.
4.
INFERENCE:
1.
2.
3.
4.
Used to create gradient for the function x and y
ABSTRACT:
The following experiment is to define a vector field calculate and
visualize its divergence and curl through MATLAB.
PROGRAM:
1.
close all % closes all opened MATLAB figures. clear all
% clears all the data in the variables clc
% Clears the command window.
2.
close all % closes all opened MATLAB figures. clear all
% clears all the data in the variables. clc
% Clears the command window.
3.
close all % closes all opened MATLAB figures. clear all % clears
all the data in the variables. clc % Clears the command window.
syms x y z % x y z variables are declared using syms command. [x,y]
= meshgrid(-2:0.2:2 , -2:0.2:2); % 2d matrix is created and with
dimensions x and y com_1 = -sin(x).*sin(y); % com_1 is initialized with
the x-component of the vector field.
com_2 = cos(x).*cos(y); % com_2 is initialized with the y-component
of the vector field. quiver(x, y, com_1, com_2) % 2-d plot of the
vector field.
d = divergence(x, y, com_1, com_2) % d is initialized with the
divergence of the vector field. hold on contour(x, y, d) % 2-d plot
of the divergence of the vector field. xlabel("x") % "x" is given
as the xlabel of the plot ylabel("y") % "y" is given as the ylabel
of the plot
4.
close all % closes all opened MATLAB figures. clear
all % clears all the data in the variables.
clc % Clears the command window. syms x y z % x y z
variables are declared using syms command. u1 = [y*sin(x*y) -x*sin(x*y)
0] % u1 is initialized with a vector field. d = divergence(u1, [x y
z]) % d is initialized with the divergence of the vector field.
5.
close all % closes all opened MATLAB figures. clear all
% clears all the data in the variables. clc %
Clears the command window.
syms x y z % x y z variables are declared using syms command.
u1 = [-y x 0]; % u1 is initialized with a vector field.
c1 = curl(u1, [x y z]) %c1 is initialized with the curl of the vector
field u1.
OUTPUT:
1.
2.
3.
4.
5.
INFERENCE:
1.
• Gradient of the scalar function is calculated using gradient()
function.
• The 2-d plot of the gradient of the scalar function is obtained using
the quiver() function. Generally 2-d plot of any vector function is
plotted using quiver() function.
2.
• Gradient of the scalar function is calculated using gradient()
function.
• The 2-d plot of the given scalar function is obtained using
contour() function. Generally 2-d plot of any scalar function is
plotted using contour() function
3.
• The divergence of a given vector field can be calculated using the
divergence() function.
• The vector field can be visualized as a 2-d plot using the quiver()
function.
4.
• The divergence of a given vector field can be calculated using the
divergence() function.
• 2-d plot of the divergence of the vector field is plotted by the
contour() function.
5.
• Curl of a given vector field is obtained from curl() function.
• The curl of the vector field with 3 variables is visualized as a 2-d
plot using the quiver3() function.