Filter löschen
Filter löschen

Last graph is plotted with no data points(figure 3) dont know why

2 Ansichten (letzte 30 Tage)
Gophela Seiphepi
Gophela Seiphepi am 18 Dez. 2022
Kommentiert: Gophela Seiphepi am 18 Dez. 2022
clc;
clear all;
close all;
% strength of signal is inversely proportional to the distance between Tx
% and Rx
d= 0:1:10
signal_strength = (1)./(d*exp(2)); % where d is the distance between Tx and Rx
figure(1)
plot(d,signal_strength) % simple plot of signal strength vs distance between Tx and Rx
title('Signal Strength against Distance of Transmission')
ylabel('Signal Strength(dBm)')
xlabel('Transmission Distance(kM)')
% signal strength equation
u = 4*pi*10*exp(-7); % constant
c = 3000000; % speed of light in kM per second
P = 500; % power transmission assumed to be 5000 watts
signal_strength_ = sqrt((u*c*P)./(2*pi*d*exp(2)));
figure(2)
plot(d,signal_strength_)
title('Signal Strength against Distance of Transmission')
ylabel('Signal Strength(dBm)')
xlabel('Transmission Distance(kM)')
% Signal Attenuation Plot
Signal_Attenuation = ((signal_strength_-30) / d)
figure(3)
plot(d,Signal_Attenuation)
title('Signal Attenuation vs Distance')
ylabel('Signal Attenuation(dB)')
xlabel('Tx to Rx Distance(kM)')
% signal attenuation plot graph is plotted without any data points and i
% cant seem to identify the problem please help...

Antworten (2)

Voss
Voss am 18 Dez. 2022
Use ./ instead of /
Signal_Attenuation = (signal_strength_-30) ./ d

Paul
Paul am 18 Dez. 2022
Hi Gophela,
See below for probable error in calculation of Signal_Attenuation and correction.
clc;
clear all;
close all;
% strength of signal is inversely proportional to the distance between Tx
% and Rx
d= 0:1:10;
d = 1×11
0 1 2 3 4 5 6 7 8 9 10
signal_strength = (1)./(d*exp(2)); % where d is the distance between Tx and Rx
figure(1)
plot(d,signal_strength) % simple plot of signal strength vs distance between Tx and Rx
title('Signal Strength against Distance of Transmission')
ylabel('Signal Strength(dBm)')
xlabel('Transmission Distance(kM)')
% signal strength equation
u = 4*pi*10*exp(-7); % constant
c = 3000000; % speed of light in kM per second
P = 500; % power transmission assumed to be 5000 watts
signal_strength_ = sqrt((u*c*P)./(2*pi*d*exp(2)));
figure(2)
plot(d,signal_strength_)
title('Signal Strength against Distance of Transmission')
ylabel('Signal Strength(dBm)')
xlabel('Transmission Distance(kM)')
Inputs to the Signal_Attenuation compuationg are both 1 x 11
% Signal Attenuation Plot
signal_strength
signal_strength = 1×11
Inf 0.1353 0.0677 0.0451 0.0338 0.0271 0.0226 0.0193 0.0169 0.0150 0.0135
d
d = 1×11
0 1 2 3 4 5 6 7 8 9 10
Using the mrdivide, / operator results in a scalar NaN, I doubt this is the desired result.
Signal_Attenuation = ((signal_strength_-30) / d)
Signal_Attenuation = NaN
Insatead, use element-wise division with the ./ operator, see rdivide, ./
Signal_Attenuation = ((signal_strength_-30) ./ d)
Signal_Attenuation = 1×11
1.0e+03 * Inf 1.8941 0.6653 0.3603 0.2330 0.1661 0.1259 0.0996 0.0813 0.0679 0.0578
figure(3)
plot(d,Signal_Attenuation)
title('Signal Attenuation vs Distance')
ylabel('Signal Attenuation(dB)')
xlabel('Tx to Rx Distance(kM)')

Community Treasure Hunt

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

Start Hunting!

Translated by