# Plotting the radiation pattern of a dipole antenna using MATLAB

I want to plot the radiation pattern of a half wavelength dipole antenna using MATLAB. But in dB scale, the plot has undesired peaks.

The code is shown below:

theta = linspace(0,2*pi,1e3);
wg =1;
k = 2*pi/wg;
l = wg/2;

U = ((cos(k*l/2*cos(theta))-cos(k*l/2))./(sin(theta))).^2;
Umax = max(U);
Un = U/Umax;

dbUn = 10*log(abs(Un));

polar(theta,dbUn)
grid minor


The plot is shown below:

Actually this is a pretty simple algorithm to implement but I do not know what I did wrong.

• Obviously, division by $\sin(\theta)$ is going to create a "peak" whenever $\sin(\theta)=0$. The question is, why did you do that? – Dave Tweed Jun 26 at 11:26
• Because, radiation pattern of the arbitrary length dipole is like that – Aldrich Taylor Jun 26 at 12:04
• It is on Balanis, Antenna Theory, 4th edition, page 172 @AJN – Aldrich Taylor Jun 26 at 13:16
• Well, I'm not going to buy a \$150 book just to check your reference, but it seems to me that you have misinterpreted the equation when you coded it for Matlab. Can you show us the original equation, with context? – Dave Tweed Jun 26 at 13:41
• @DaveTweed An equation for electric field can be found on antenna-theory.com/antennas/dipole.php – AJN Jun 26 at 13:43