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

조회 수: 5 (최근 30일)
柊介 小山内
柊介 小山内 2023년 1월 14일
댓글: 柊介 小山内 2023년 1월 15일
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)

채택된 답변

KALYAN ACHARJYA
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 CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by