why is there an error in line 13 of my coding ?

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,10,20,30,40,50,60,70,80,100]; %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 Loss (dB) vs Distance for surburban
figure(1) %Enables the figure
plot(f,L); %versus plotting command
title('Distance vs Loss (dB) for suburban 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]

Answers (2)

Walter Roberson
Walter Roberson on 26 Nov 2020
Lfsl = 10*log((((3*10^8)./f)).^2)/((4*pi)^2).*d.^2; % finding free space loss

Alan Stevens
Alan Stevens on 26 Nov 2020
In addition to Walter's correction, note that f and d contain a different number of elements, so element by element operations will also fail.

Community Treasure Hunt

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

Start Hunting!