Friday, 3 May 2013

Radiation pattern of Half wave dipole in MATLAB

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



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;
 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,'antennatutorials.com');
 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);
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,'antennatutorials.com');
elseif choice==3
    break
end
end




Resutls:::::---




5 comments:

  1. I find this blogger an inspiration and is definitely worth following. I've became a subscriber too, so please keep me updated. thanks once again.

    Chancy
    www.gofastek.com

    ReplyDelete
  2. Can you write code for patch or meander. Line antenna please

    ReplyDelete
  3. thanks a lot, I was wondering how to plot the 3D pattern. This really helped me

    ReplyDelete
  4. what is x y and z axcis in this

    ReplyDelete
  5. what is x y and z axcis in this

    ReplyDelete