Wednesday, 8 May 2013

Radiation pattern and parameters of half wave dipole in MATLAB


Please copy and the paste the following code in matlab editor or matlab command window.
Run the program.

%MATLAB program by antennatutorials.com
while (1)
choice=menu('Radiation pattern & parameters of half wavelength dipole by antennatutorials.com (select your choice)','Three dimensional plot','Two dimensional plot','Parameters','exit');
if choice == 1
    %radiation pattern of half wave dipole in three dimension
clear all
clc
theta=linspace(0,pi,100);
 phi=linspace(0,2*pi,100);
 [theta, phi]=meshgrid(theta,phi);
 r=abs((sin(theta)).^3);
 x=r.*(sin(theta)).*cos(phi);
 y=r.*(sin(theta)).*sin(phi);
 z=r.*cos(theta);
 figure(1);
 mesh(x,y,z);
 %view(127.5,30)
 xlabel('x axis');
 ylabel('y axis');
 zlabel('z axis');
 title('Radiation pattern of half wavelength dipole by antennatutorials.com','color','b');
 axis equal;
 text(-1,1,0.4,'antennatutorials.com');
 grid on;
elseif choice ==2
    %radiation pattern of half wave dipole in two dimension
clear all
clc
theta=linspace(0,2*pi,500);
r=abs((sin(theta)).^3);
x=r.*(sin(theta));
z=r.*cos(theta);
figure(2);
plot(x,z);
 xlabel('x axis');
 zlabel('z axis');
 title('Two dimensional Radiation pattern of half wavelength dipole by antennatutorials.com','color','b');
 axis ([-1 1 -0.5 0.5]);
 zlabel('zaxis')
 ylabel('yaxis')
 legend(' at phi=90')
 text(-1,0.38,'antennatutorials.com');
 grid on;
elseif choice==3
    % Half power BEAMWIDTH of half wave dipole
%HPBW
clc
syms x;
m=solve('(cos((pi/2)*cos(x)))/sin(x)=0.707');
m1=sym2poly(m);
degree=m1*180/pi;
rounddegree=(rem(degree,360))+360;
HalfPowerBW=180-2*rounddegree;
%directivity of half wave dipole
dprad=@(theta) (cos((pi/2)*cos(theta)).^2)./sin(theta);
prad=quad(dprad,0,pi);
Directivity=2/prad;
figure(4);
title([{'Directivity &', num2str(Directivity);'half power Beamwidth of \lambda/2 dipole are respectively ',num2str(HalfPowerBW)}],'color','b','fontsize',22)
axis off;
h=figure(4);
set(h,'position',[300 200 800 200]);
elseif choice==4
    break;
end
end

No comments:

Post a Comment