Plotting Radiation Pattern in 3D (in dB)

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

> 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);
This code also fails to generate any pattern.
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.
.
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);

Sign in to comment.

Answers (0)

Categories

Asked:

on 3 Feb 2022

Commented:

on 14 Feb 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!