Simulating a hertzian dipole

조회 수: 11 (최근 30일)
basem ehab
basem ehab 2017년 7월 24일
댓글: SHYAM 2024년 3월 29일
Hi everyone, I am trying to create a code that simulates the electric field in the radial direction of a Hertzian Dipole Antenna. No matter what I try to change I was never able to produce the right figure. Here's my code:
clear
clc
epsilon= 8.85e-12;
f = 3e9;%frequency
c = 3e8;%speed of light
w = 2*pi*f;%omega
lambda = c/f;%wavelength
B = 2*pi/lambda; %beta
dl = lambda/30;
dt=1/f/90;
I0 = 1;%current
[x,z]=meshgrid(-lambda:dl:lambda,-lambda:dl:lambda);
r = (x.^2+z.^2).^(1/2);
theta = atan(x./z);
n = B/(w*epsilon);
E1 = n*I0*dl/(2*pi);
E2 = cos(theta);
E3 = r.^(-2)-r.^(-3)*1i/B;
E4 = exp(-1i*B*r);
E =E1*E2.*E3.*E4;%r component of the field
n= 1000;
M = moviein(n);%creating the movie
for i=1:n
t=i*dt;
Et=real(E*exp(1i*w*t));%converting to time domain
contour(Et)
M(i) = getframe;
end
movie(M)%plotting the movie
Any ideas?
Thanks in advance!

채택된 답변

Vinod Dwarapudi
Vinod Dwarapudi 2021년 6월 25일
I have changed the scaling of Contour plot and reduced the length of the antenna. Also replaced variable 'i' to 'xx' to not get confused between imaginary value 'i' and variable 'i'.
clear
clc
epsilon= 8.85e-12;%fre space permitivity
f = 3e9;%frequency
c = 3e8;%speed of light
w = 2*pi*f;%omega
lambda = c/f;%wavelength
B = 2*pi/lambda; %beta
dl = lambda/500; %length of antenna
dt=1/f/20;
I0 = 1;%current
[x,z]=meshgrid(-lambda:dl:lambda,-lambda:dl:lambda);
r = (x.^2+z.^2).^(1/2);
theta = atan(x./z);
n = B/(w*epsilon);
E1 = n*I0*dl/(2*pi);
E2 = cos(theta);
E3 = r.^(-2)-r.^(-3)*1i/B;
E4 = exp(-1i*B*r);
E =E1*E2.*E3.*E4;%r component of the field
n= 100;
% M = moviein(n);
M(n) = struct('cdata',[],'colormap',[]);%Initializing Matrix to store frames
h = figure;
ax = gca;
ax.NextPlot = 'replaceChildren';
h.Visible = 'off';%Hiding figure for speed up
v = -1:0.13:1;%parameter for scaling contour plots
for xx=1:n
t=xx*dt;
Et=real(E*exp(1j*w*t));%converting to time domain
contour(Et,v)
drawnow
M(xx) = getframe;
end
h.Visible = 'on';
movie(M);shg
Also, the dipole can be simulated using Antenna Toolbox. Below are some of the links that can help you with that :
d = dipole('Length',value) creates dipole of any required length. Refer below link to perform the analysis and get the impedance, radiation pattern etc...
  댓글 수: 1
SHYAM
SHYAM 2024년 3월 29일
Excellent. In the same way , how to do for magnetic field and far fields? Please help me with the code snippet

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by