why when i plot the graph for the okumura model it doesnt show line?

1 view (last 30 days)
%Matlab cache clearing commands
clc; %clears command window
clear all; %clears workspace variables
close all; %closes all external matlab windows
%input starts here
Hte=100; %Base Station Height between 30 m and 1000 m
Hre=10; %Mobile Station Antenna Height between 1 m and 10 m
d =1; %distance from base station between 1Km and 100Km
f=900; %Frequency between 150Mhz and 1920Mhz
Amu = 18; %Median attenuation
Kcor =9; %Correction factor
%SUBURBAN AREA
for i=1:length(f)
Lfsl = 10*log((((3*10^8)/f(i))^2)/((4*pi)^2)*d^2); % finding free space loss
Ghte = 20*log(Hte/200); % Base station antenna height gain factor
if(Hre>3)
Ghre = 20*log(Hre/3); % Mobile station antenna height gain factor
else
Ghre = 10*log(Hre/3);
end
L(i) = Lfsl+Amu(i)-Ghte-Ghre-Kcor(i); % formula for path loss
end
disp(L) %prints the Loss Array
% plot of Distance vs Loss (dB) for surburban
figure(1) %Enables the figure
plot(f,L); %versus plotting command
title('Distance vs Loss (dB) for open area for Okumura Model'); %title of the plot
xlabel('Distance(Km)'); %label for X-axis
ylabel('Propagation Path loss(dB)'); %label for Y-axis
grid on; %Enables Grid feature in plot
%inputs
% 50
% 5
% 10
% [200 300 400 500 600 700 800 900 1000 1100]
% [20.4 20.45 20.5 20.55 20.6 20.65 20.7 20.75 20.8 20.85]
% [23 24 25 25.5 26 27 27.5 28 28.75 29]

Accepted Answer

Stephan
Stephan on 26 Nov 2020
Edited: Stephan on 26 Nov 2020
f is a scalar here - for this reason you have only one data point. Either use scatter to visualize the point or make f an array of values that you are interested in (this is waht i did here). Also you dont need a loop - your code can be vecotrized:
%Matlab cache clearing commands
clc; %clears command window
clear all; %clears workspace variables
close all; %closes all external matlab windows
%input starts here
Hte=100; %Base Station Height between 30 m and 1000 m
Hre=10; %Mobile Station Antenna Height between 1 m and 10 m
d =1; %distance from base station between 1Km and 100Km
f=200:900; % MADE AN ARRAY FROM f %Frequency between 150Mhz and 1920Mhz
Amu = 18; %Median attenuation
Kcor =9; %Correction factor
%SUBURBAN AREA
Lfsl = 10*log((((3*10^8)./f)).^2)/((4*pi)^2)*d^2; % finding free space loss
Ghte = 20*log(Hte/200); % Base station antenna height gain factor
if(Hre>3)
Ghre = 20*log(Hre/3); % Mobile station antenna height gain factor
else
Ghre = 10*log(Hre/3);
end
L = Lfsl+Amu-Ghte-Ghre-Kcor; % formula for path loss
disp(L) %prints the Loss Array
% plot of Distance vs Loss (dB) for surburban
figure(1) %Enables the figure
plot(f,L); %versus plotting command
title('Distance vs Loss (dB) for open area for Okumura Model'); %title of the plot
xlabel('Distance(Km)'); %label for X-axis
ylabel('Propagation Path loss(dB)'); %label for Y-axis
grid on; %Enables Grid feature in plot
%inputs
% 50
% 5
% 10
% [200 300 400 500 600 700 800 900 1000 1100]
% [20.4 20.45 20.5 20.55 20.6 20.65 20.7 20.75 20.8 20.85]
% [23 24 25 25.5 26 27 27.5 28 28.75 29]

More Answers (0)

Categories

Find more on 2-D and 3-D 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!