3 views (last 30 days)
Mingcheng Tsai on 29 Aug 2019
Hi, I would like to draw the same figure below from the two reference equations. However, the figure I obtained was not quite similar to what I wanted.
Here is my code for the simulation.
Plot a Figure of Spetrum power
theta = -100/180*pi:5*pi/180:100/180*pi;
%plot(theta*180/pi,sin(theta))
Gain=[]
cell_radius = [10 5 2] %km
HAP_altitude = 20 %km
Gain(i,:) = 0.7*(2*besselj(1,70*pi/phi_3db.*sin(theta))./sin(theta)).^2
plot(theta*180/pi,10*log(mapminmax(Gain(i,:), 0, 1)))
hold on
end
legend('10km','5km','2km')
My result is below.
Thank you so much in advance.

David Goodmanson on 30 Aug 2019
Edited: David Goodmanson on 30 Aug 2019
Hello MT,
The basic issue is setting phi_3db to degrees, but there may also be a problem with the basic definition of phi_3db (more on that shortly). The conversion is not
with the conversion factor in the argument of atan, but rather
with the conversion factor outside. (Also, conversion to dB requires log10, not log).
Rather than having a bunch of factors of 180/pi floating around, the code below uses the sind and atand functions.
I don't have the mapminmax function (Deep Learning Toolbox) so I just normalized G in the usual way and didn't worry about mapping the minimum to zero.
Major functionality in toolboxes is is one thing, that's what toolboxes are for. But Mathworks has gotten good at creating simple, short 'convenience' toolbox functions that actually make things a lot less less convenient for people who want to run some vanilla piece of code and don't have all the toolboxes. Is it a ploy to force people to buy more toolboxes? Probably not. The effect is the same, though.
The plot looks a lot better after converting to degrees in eqn (2)
But eqn (2) does not quite reproduce the figure. Interestingly, the equation
does reproduce the figure. So now we have the choice, is eqn (2) correct and the figure incorrect? Or are both eqn (3) and the figure correct, and eqn (2) incorrect?
%Plot a Figure of Spectrum power
theta = (-100:.01:100);
Gain=[]
cell_radius = [10 5 2] %km
HAP_altitude = 20; %km
% phi_3db = 2*atand(cell_radius(i)/HAP_altitude) % (2) original
phi_3db = atand(2*cell_radius(i)/HAP_altitude) % (3) modified
Gain(i,:) = 0.7*(2*besselj(1,(70*pi/phi_3db)*sind(theta))./sind(theta)).^2;
figure(1)
plot(theta,10*log10((Gain(i,:)/max(Gain(i,:)))))
hold on
end
legend('10km','5km','2km')
hold off
David Goodmanson on 2 Sep 2019
Hello MT,
I appreciate your comment. Once you determine the correct expression and plot, I would be interested to hear what they are.

R2019a

### Community Treasure Hunt

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

Start Hunting!

Translated by