how can eliminate negative data in erf function?

조회 수: 1 (최근 30일)
leuva
leuva 2023년 3월 10일
댓글: leuva 2023년 3월 14일
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
Arka
Arka 2023년 3월 10일
편집: Arka 2023년 3월 10일
Do you want to remove the negative data points from the term1, term2, and term3 vectors?
leuva
leuva 2023년 3월 10일
yes

댓글을 달려면 로그인하십시오.

채택된 답변

Alan Stevens
Alan Stevens 2023년 3월 10일
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
Alan Stevens
Alan Stevens 2023년 3월 11일
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?
leuva
leuva 2023년 3월 14일
yes sir ..i have to check it and thankyou so much for replying

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by