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

2 visualizzazioni (ultimi 30 giorni)

Commentato: 柊介 小山内 il 15 Gen 2023
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 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposta accettata

KALYAN ACHARJYA il 14 Gen 2023
Modificato: KALYAN ACHARJYA il 14 Gen 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.
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti

thank you. I can resolve problem!

Accedi per commentare.

### Categorie

Scopri di più su Assumptions in Help Center e File Exchange

R2021a

### Community Treasure Hunt

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

Start Hunting!

Translated by