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.
  1 件のコメント
柊介 小山内
柊介 小山内 2023 年 1 月 15 日
thank you. I can resolve problem!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by