```
clc;
clear all;
%% satellite communication Problem 1, Free Space Loss
% The distance increases non-linear.
d = [0.05 2 4 6 8 10 15 20 25 30 40 50 60 70 80 90 100];
% The measured Received Signal Strength Indicator are expressed in dB.
RSSI = [-20 -50 -60 -62 -68 -67 -81 -82 -83 -80 -88 -84 -88 -92 -86 -90 -98];
% The FSL equation and its results are expressed in dB as well.
lambda = 0.35; %wavelength
L = 20*log10(lambda)-20*log10(d)-21.98;
% Defining a fit type to match the Loss equation for the curve fit.
myfittype = fittype('a + 20*log10(0.35) - 20*log10(x)');
% Fitting a curve onto measured RSSI and distance:
dFit = reshape(d, [17,1]);
RSSIFit = reshape(RSSI, [17,1]);
% Reshaping data to fit the function
FitCurve = fit(dFit, RSSIFit, myfittype)
plot(d,RSSI,'r o',d,L,'b--o')
% Setting identical y limits
hold on
plot(FitCurve)
hold off
grid on
title('Plots of RSSI dots and curve and FSL equation');
xlabel('distance (m)');
ylabel('dB');
legend( 'RSSI measurements','Analytical FSL curve','RSSI measurement curve fit', 'Location','northeast','Orientation','vertical');
print FitCurve
```