how can eliminate negative data in erf function?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
leuva
am 10 Mär. 2023
Kommentiert: leuva
am 14 Mär. 2023
clc;
clear all;
close all;
N = 30 ;
mu =N*pi/4;
M = N*(1-(pi/16));
lemdaD = 2;
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)
e1(i) = sqrt(M.*v2(i)+lemdaD)
e2(i) = sqrt(2*M*lemdaD)
e3(i) = M.*v1(i).*v2(i)
e4(i) = (lemdaD.*v1(i))./v2(i)
e5 = lemdaD*mu
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 Kommentare
Akzeptierte Antwort
Alan Stevens
am 10 Mär. 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.
3 Kommentare
Alan Stevens
am 11 Mär. 2023
If the equation is correct then perhaps some part of your input data is incorrect; otherwise, why do you want to remove the negative values?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Transforms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!