0% found this document useful (0 votes)
101 views

MATLAB Code For Plotting 3D Patterns

This MATLAB code plots a 3D dipole pattern by generating the electric field strength (E) as a function of theta and phi angles, converting to Cartesian coordinates, and displaying the results as a 3D mesh plot that can be viewed from different angles.

Uploaded by

Wasyhun Asefa
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views

MATLAB Code For Plotting 3D Patterns

This MATLAB code plots a 3D dipole pattern by generating the electric field strength (E) as a function of theta and phi angles, converting to Cartesian coordinates, and displaying the results as a 3D mesh plot that can be viewed from different angles.

Uploaded by

Wasyhun Asefa
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

MATLAB code for plotting 3D patterns % The following code is an example of how to plot a % 3-D pattern.

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

% You can change the viewpoint using view

You might also like