# Good day im trying to plot a graph of the effect of distance of separation between the TX/RX and the receive signal strength, using Friis's free space equation. I am having an issue with the graph when my pr is in db unit.

11 views (last 30 days)
Yashlin Naidoo on 28 Apr 2018
Answered: John Barber on 10 Dec 2022
My code:
clc;
close all;
clear all;
d=1:0.1:20 ;
f=2100000000;
Wavelength=(3*10^8/f).^2;
PT=50.12;
PR=(Wavelength./(4*pi*d).^2)*PT ;
PR1=10*log(PR/(10*10.^-3)) ;
subplot(2,1,1);
plot(d,PR);
xlabel('x--> D (distance in Km)');
ylabel('y--> PR (path loss)');
title('Distance of separation between the TX/RX and the receive signal strength');
grid on
subplot(2,1,2);
plot(d,PR1);
xlabel('x--> D (distance in Meter)');
ylabel('y--> PR (Path loss in dB)');
title('Distance of separation between the TX/RX and the receive signal strength');
grid on;
Yashlin Naidoo on 28 Apr 2018
My pr linear value when converted to dbm doesnt correspond to the graph value.
Stephan on 29 Apr 2018
Edited: Stephan on 29 Apr 2018
Hi,
sorry i guess my answer didnt help - deleted it. What exactly is the difference between your result from calculation and the plot? Are you sure the unit of the second x-values is m instead of km?
Best regards
Stephan

Wick on 1 May 2018
Edited: Wick on 1 May 2018
You're plotting exactly what you're asking for. However, I don't think you're asking what you think you're asking. Your definition of PR1 doesn't appear to reference P0. It's a fixed scalar of 0.01;
PR1=10*log(PR/(10*10.^-3)) ;
did you intend to divide by 0.01? That's what 10*10.^-3 evaluates to. I would have expected PT there. Perhaps you intended 0.001? That's just '1e-3' in MATLAB notation (without the quotes).
Edit: Also, in MATLAB, log is the natural log (base e) usually written as ln. If you want the base 10 log the command is log10. dB is usually defined in base 10.

John Barber on 10 Dec 2022
Power Transmitted Vs. Distance
clc; clear; close all;
%%%%%% Pt(dBm) Vs Distance (m) MATLAB Code %%%%%
%%% desined By Braden Gustitis & John Barber %%%
%%%%%%%%% Senior Design Project ENGR 402 %%%%%%%
%%%%%% Used PTx Vs Distance calculator to validate MATLAB results %%%%%%
C=3.0e8; % Speed of light
f0 = 2.4e9; % Frequency
Lambda = C/f0; % Wavelength
Gr = 2; % Receiver gain (estimated)
Gt = 2; % Transmitter gain (estimated)
Pt = 80:-5:0; % Tx power from 80 dBm to 0 dBm
i = 1:length(Pt);
%%%%%%%%%%%%%%% Per ScreenBeam %%%%%%%%%%%%%%
PrR = -67; % P Rx Reliable -67 dBm
PrG = -60; % P Rx Good -60 dBm
PrE = -50; % P Rx Excellent -50 dBm
%%%%%%%%%%% Pt -
LfsR = Pt-PrR; % difference between PTx & PRx ==> Pt - PrR Reliable
LfsG = Pt-PrG; % difference between PTx & PRx ==> Pt - PrG Good
LfsE = Pt-PrE; % difference between PTx & PRx ==> Pt - PrE Exellent
% XR, XG, XE to simplify exponent in below equation
XR = LfsR + Gr + Gt;
XG = LfsG + Gr + Gt;
XE = LfsE + Gr + Gt;
% Freespace Pathloss equation modified to output distance
RR = (Lambda .* 10 .^ ((XR)/20)) ./ (4 .* pi); % Reliable ~ -67 dBm
RG = (Lambda .* 10 .^ ((XG)/20)) ./ (4 .* pi); % Good ~ -60 dBm
RE = (Lambda .* 10 .^ ((XE)/20)) ./ (4 .* pi); % Excellent ~ -50 dBm
figure
plot(RR,Pt(i), 'DisplayName', 'Pr = -67dBm "Reliable"')
title('R(Pt) of 2.4 GHz')
xlabel('Distance in meters')
ylabel('Pt in dBm')
xlim([0 5000]); % change to adjust distance
grid on
hold on
plot(RG, Pt(i), 'DisplayName', 'Pr = -60dBm "Good"')
plot(RE, Pt(i), 'DisplayName', 'Pr = -50dBm "Exellent"')
legend(Location="northwest")
legend(fontsize=14)
legend show
hold off

### Categories

Find more on Antennas, Microphones, and Sonar Transducers 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!