
while (1)
choice=menu({'Radiation pattern of half wavelength dipole (select your choice)';'By antennatutorials.com'},'Three dimensional plot','Two dimensional plot','exit')
if choice == 1
    %radiation pattern of half wave dipole in three dimension
%By www.antennatutorials.com
clear all
clc
theta=linspace(0,pi,100);
 phi=linspace(0,2*pi,100);
 [theta, phi]=meshgrid(theta,phi);

 %r=(sin(theta)).^3;
 
 
 %%%%%%%%% This is where you can modify the parameters (d and N)
 d=0.82; % distance/wave length (d/lambda)
 N=2;    % number of antennas
 
 
 
 AF = abs( sin(N*pi*d.*cos(theta))  ./  (N*sin(pi*d.*cos(theta))) ) ;
 CE = cos((pi/2)*cos(theta))./sin(theta);

 r = AF.*CE;
  
 
 x=r.*(sin(theta)).*cos(phi);
 y=r.*(sin(theta)).*sin(phi);
 z=r.*cos(theta);
 figure(1);
 mesh(x,y,z);
 xlabel('x axis');
 ylabel('y axis');
 zlabel('z axis');
 title('Radiation pattern of half wavelength dipole by antennatutorials.com','color','b');
 text(-1,1,0.4,'3D');
 axis equal;
 grid on;
elseif choice ==2
    %radiation pattern of half wave dipole in two dimension
%By www.antennatutorials.com
clear all
clc
theta=linspace(0,2*pi,500);
%r=abs((sin(theta)).^3);

 d=0.82;
 N=1;
 
 AF = abs( sin(N*pi*d.*cos(theta))  ./  (N*sin(pi*d.*cos(theta))) ) ;
 CE = cos((pi/2)*cos(theta))./sin(theta);

 r = AF.*CE;
 

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')
 grid on;
  text(-1,0.38,'2D');
elseif choice==3
    break
end
end
