# how can eliminate negative data in erf function?

3 views (last 30 days)
leuva on 10 Mar 2023
Commented: leuva on 14 Mar 2023
clc;
clear all;
close all;
N = 30 ;
mu =N*pi/4;
M = N*(1-(pi/16));
avgsnr = 0.0001;
p = 100
n = 3.5;
deld =1e-3 * 10^(0/10); % 0 dBm in watts;
delr = 10^(-80/10)/1000; % -80 dBm in watts
delrd =deld+(p^2)*delr;
w = [0:1:40]
ps = zeros(size(w));
for i = 1:length(w)
%for j= 1:1:5
ps(i) = 10.^(w(i)./10)./1000;
dsr = 41.23;
drd = 60.82;
dsd =100;
d0 =1
avgsnrd(i) = (ps(i)./delrd);
b1(i) =sqrt(avgsnrd(i)).*p*(dsr*drd/d0^2)^(-0.5*n)
b2(i) = sqrt(avgsnrd(i)).*(dsd/d0)^(-0.5*n)
v1(i) = 1./b2(i)
v2(i) = b1(i)./b2(i)
e3(i) = M.*v1(i).*v2(i)
sqrt_avgsnr = sqrt(avgsnr)
d1(i)= 1./b1(i)
term1(i) = 0.5 .* (erf((d1(i).*sqrt_avgsnr - mu)./ sqrt(2* M)) + ...
erf(mu/sqrt(2 * M)))
term2(i) = (sqrt(lemdaD)./(2.*e1(i))).*exp(-(v1(i).*sqrt_avgsnr - v2(i).* mu).^2./(2.*e1(i).^2)).*....
erf((e4(i).*sqrt_avgsnr - e5)./(e1(i) .* e2(i)))
term3(i)= (sqrt(lemdaD)./(2.*e1(i))).*exp(-(v1(i).*sqrt_avgsnr - v2(i).* mu).^2./(2.*e1(i).^2)).* ....
erf((e3(i).*sqrt_avgsnr + e5)./(e1(i) .* e2(i)))
FyD1(i) = term1(i) - term2(i) - term3(i)
%FyD11(i) = abs(FyD1(i))
end
semilogy(w, max(FyD1, 0), '-or')
legend('p = 0 dB')
%,'p = 10 dB','p = 15 dB','p = 20 dB')
xlabel('ps(dBm)')
ylabel('Pout')
##### 2 CommentsShow 1 older commentHide 1 older comment
leuva on 10 Mar 2023
yes

Alan Stevens on 10 Mar 2023
Should
term2(i) = (sqrt(lemdaD)./(2.*e1(i))).*exp(-(v1(i).*sqrt_avgsnr - v2(i).* mu).^2./(2.*e1(i).^2)).*....
erf((e4(i).*sqrt_avgsnr - e5)./(e1(i) .* e2(i)));
be
term2(i) = (sqrt(lemdaD)./(2.*e1(i))).*exp(-(v1(i).*sqrt_avgsnr - v2(i).* mu).^2./(2.*e1(i).^2)).*....
erf((e4(i).*sqrt_avgsnr + e5)./(e1(i) .* e2(i)));
i.e. have a " + e5" instead of " - e5"?
This removes the negatives.
leuva on 14 Mar 2023
yes sir ..i have to check it and thankyou so much for replying

### Categories

Find more on Bounding Regions 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!