MATLAB Code For Plotting 3D Patterns
MATLAB Code For Plotting 3D Patterns
For simplicity, it plots the 3-D pattern of a short % dipole oriented along the Z-axis (E = sin(theta)) i=1; deltatheta = 0.2; deltaphi = 1; for (phi = 0:deltaphi:360) j=1; for(theta = 0:deltatheta:360) E(i,j) = sin(theta*pi/180); j=j+1; end i=i+1; end phi = (0:deltaphi:360)*pi/180; theta= (0:deltatheta:360)*pi/180; [PHI,THETA] = meshgrid(phi,theta); R = abs(E)'; X=R.*sin(THETA).*cos(PHI); Y=R.*sin(THETA).*sin(PHI); Z=R.*cos(THETA); mesh(X,Y,Z) xlabel ('X') ylabel('Y') zlabel ('Z') % When you run this code in MATLAB, you will get the following 3-D % pattern % Convert from spherical to Cartesian % coordinates