Plotting Radiation Pattern in 3D (in dB)
Show older comments
I am trying to plot the radiation pattern of cos^9(theta) in matlab where theta is the elevation. The code I have so far is the following:
theta = linspace(-pi/2, pi/2);
phi = linspace(0, pi);
[phi, theta] = meshgrid(phi, theta);
rho = 10.*log10((cos(phi)).^9) + 30;
[x,y,z] = sph2cart(phi, theta, rho);
mesh(x,y,z);
The issue is that the log of the cosine creates complex values that cannot be plotted (I do not wish to plot these values either). How should I fix the above code?
I also have access to patternCustom in the antenna toolbox but I am unsure how to use it.
Thank you for your time, help, and advice.
3 Comments
Jon Ho
on 3 Feb 2022
Prahlad Gowtham Katte
on 14 Feb 2022
Edited: Prahlad Gowtham Katte
on 14 Feb 2022
Hello @Jon Ho
I tried the following piece of code in MATLAB R2021b
theta = linspace(-pi/2+0.1,pi/2-0.1);
phi = linspace(0,2*pi);
rho = 10.*log10((cos(theta)).^9) + 30;
patternCustom(rho,theta,phi);
I got the above figure as output.If the problem is not yet solved , please tell the version of MATLAB which you are using currently.
.
Mathieu NOE
on 14 Feb 2022
helo
I simply added an abs to your code to avoid taking the log of negative data but I'm unsure this is making sense...

theta = linspace(-pi/2, pi/2,100);
phi = linspace(0, pi,100);
[phi, theta] = meshgrid(phi, theta);
rho = 10.*log10(abs((cos(phi)).^9)) + 30; % <= here
[x,y,z] = sph2cart(phi, theta, rho);
mesh(x,y,z);
Answers (0)
Categories
Find more on Polar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!