Anonymous Function soustraction problem with a parameter
Afficher commentaires plus anciens
Hello. ı want to plot a correlation between the received power (Pr(dB)) and the frequency (f)(variable of an anonymous function PL_dB). my equation is Pr_dB = @(f) TXPower - PL_dB(f);
where Pr_dB is the received power,
TXPower the transmitted power. TXPower is a parameter that can be enter from the GUI,
PL_dB the path loss. it is function of the frequency f.
the problem with the code is that the Pr(dB) gives me wrongs answers.
Pr_dB =30 -102= -72 but the code gives me 41 as Pr_dB value. Can someone please help me with that? here below is the code.

close all;
clear variables;
clc;
%--------------------------------------------------------------------------
SF=4.0;% Shadow fading standard deviation in dB
d0=1;% Free space reference distance in meters
c = 3e8; %% speed of light (m/s)
h_BS = 15; % Base station height in meters (10-150 m), only used for the RMa scenario
TXPower=30;
TRDistance= 100;
lambda = @(f) (c/(f*1e9));
%Path Loss
PL_dB =@(f)( 20*log(4*pi*d0*f*1e9/c) + 30.7*(1-0.049*((h_BS-35)/35))*log((TRDistance)) + SF*randn);
%Received power
Pr_dB =@(f) TXPower - PL_dB(f);
%verify (PL_dBm), (Pr_dBm)and (TXPower) values
fprintf('the path loss is %d , the received power is %d .\n ',func2str(PL_dB) ,func2str(Pr_dB));
fprintf('the TX is %d .\n',(TXPower));
%ploting the the recived power depending on the frequency
figure;
fplot(Pr_dB, [1,28]);
xlabel('f');
ylabel('Pr_dB');
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!