error on piecewise 'First argument must be a condition.'
7 次查看(过去 30 天)
显示 更早的评论
I want to calculate SNR as below, but error message 'First argument must be a condition.'displayed. I think first argument is condition so I can't understand why my expression is bad. please tell me what is the problem of my code.
%% parameter
syms TOP
Fp=48;
Nch=103;
Rch=0.064;
delta=0.0875;
B=9;
h = 6.62e-34;
F = 10^0.5;
c=299792458;
lamda=1577.5e-9;
G = 10^0.95;
NS=133;
gammaS=1.3;
betaS=21.7;
alfaS=0.023;
%% calculation
ASES = NS*h*c/lamda*F*(Rch*1e+12)*(G-1);
etaS = NS*4*gammaS^2/(27*pi*betaS*alfaS*(Rch)^2)*asinh(pi^2*betaS/(4*alfaS)*(Rch)^2*Nch^(2*Rch/delta));
popt=(ASES/(2*etaS))^(1/3);
NLIS = etaS*(0.001*(TOP/Nch))^3;
SNR1 = (0.001*(TOP/Nch))/(ASES+NLIS)*0.5;
SNR2=popt/(1.5*ASES)*0.5;
pch =(0.001*(TOP/Nch));
SNR = piecewise(pch<popt,SNR1,0,SNR2);
T = Fp*2*Rch/delta*B*log2(1+SNR)
0 个评论
采纳的回答
KALYAN ACHARJYA
2023-1-14
编辑:KALYAN ACHARJYA
2023-1-14
As per the syntax definition of the piecewise funtion
piecewise(condition, value, condition, value....)
In the above code
SNR = piecewise(pch<popt,SNR1,0,SNR2);
%.............................^ is that condition
Here modification
piecewise(condition, value, otherwise)
SNR = piecewise(pch<popt,SNR1,SNR2);
Pls check as per requirements.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!