Info

This question is closed. Reopen it to edit or answer.

My IF function for a set of data is not working.

1 view (last 30 days)
Aizwan Aziz
Aizwan Aziz on 22 Nov 2020
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi,
I have a set of data d3, ranging from 1 to 100. For value Da that is less than 48, it will need to use the formula to get value of X. Any Da value that is more that 48 will have value of Grx. But it seems that my code does not work. Can anyone help me. Thank you...
d3=1:1:100;
Grx=-10
Hbs=30; %5G BS Height
LUA=77; %FSS antenna look up angle
Hypo=sqrt(Hbs.^2+d3.^2); %hypotenuse
Y=acsc(Hypo/Hbs)*(180/pi()); %angle between BS & FSS
Da=LUA-Y %diff angle
if Da<48
X=32-25*log10(LUA-Y)
else
X=Grx
end
Lp3= -27.55+20*log10(f)+20*log10(Hypo); %PL diff height
B_lev3=PdBm+Gtx-Lp3+X-Lmisc; %blocking level w/o filter, dbm
B_lev4=PdBm+Gtx-Lp3+X-Lmisc-Fs; %blocking level w filter, dbm
subplot(2,1,1);
plot(d3,B_lev3,'m');
xlabel('D (distance in m)');
ylabel('Blocking level (dBm)');
title('Signal Power from 5G BS (Diff Antenna Height w/o filter)');
grid on

Answers (1)

Alan Stevens
Alan Stevens on 22 Nov 2020
You could replace
if Da<48
X=32-25*log10(LUA-Y)
else
X=Grx
end
by the following
id = find(Da<48);
X(id)= 32-25*log10(Da(id));
id2 = find(Da>=48);
X(id2) = Grx;
However, you should note that, since LUA-Y has some negative values you will end up with complex values for Da and X.
Also, you have other parameters in later lines that are not defined.
  3 Comments
Alan Stevens
Alan Stevens on 22 Nov 2020
As long as all the terms are defined (f doesn't seem to be, so Lp3 won't be) then you can simply
plot(d3,B_lev3)

Community Treasure Hunt

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

Start Hunting!