Hi Maximiliano,
Before getting to the plot, there are a couple of things in the code that need to be changed. [1] In the multiplier, there should be some more parentheses included so that you are dividing by r instead of multiplying by it. [2] Since all units are in cm, you need a different value for c than 3e8. Anyway I will assume that you have a good function of E_phi vs. phi.
From the Eplane plot it looks like you want directivity and not gain, i.e. 0 dB as the maximum value. The following code is an example of such a plot, which has multiple curves but certainly works for just one. You can make the obvious change to have the angle go counterclockwise as in the Eplane plot.
I thought that the polaraxes command would work conveniently like the rlim command does, but not so. It looks like it can be made to work, but it’s a hassle. The ‘get’ command does a good job.
theta = (-1:.001:1)*pi;
lambda = 1;
d = lambda*[1/50 1/4 1/2 3/4 1]';
k = 2*pi/lambda;
kd2 = k*d/2;
[THeta Kd2] = meshgrid(theta,kd2);
y = (cos(Kd2.*cos(THeta))-cos(Kd2))./sin(THeta);
y = 20*log10(abs(y));
ymax = max(y,[],2);
y = y-ymax;
y(y<-40) = -40;
fig(1)
polarplot(theta,y)
rlim([-40 0]);
set(gca,'thetazerolocation','top','thetadir','clockwise');
legend('lambda/50','lambda/4','lambda/2','3 lambda/4','lambda')
Best Answer