error on piecewise 'First argument must be a condition.'

7 visualizaciones (últimos 30 días)
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)

Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 14 de En. de 2023
Editada: KALYAN ACHARJYA el 14 de En. de 2023
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.

Más respuestas (0)

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by