if statement with ge and &
1 回表示 (過去 30 日間)
古いコメントを表示
I don't understand why the following line is producing an error:
if j ge 2 & cANALY(i+1,j-1) < 0
j is a scalar and cANALY(i+1,j-1) is an element in the array cANALY. So why the error "Too many input arguments".
0 件のコメント
回答 (1 件)
Rik
2021 年 6 月 13 日
You should write this instead:
if j >= 2 && cANALY(i+1,j-1) < 0
2 件のコメント
Steven Lord
2021 年 6 月 13 日
If you wanted to use the function form of the operator >= you would have to call it with the two quantities you wanted to compare inside the parentheses.
5 >= 4 % true
ge(5, 4) % also true
Putting the function between the two inputs won't work. That only works with the operator. Most people just use the operator form, but people writing classes need to know that ge is the function form of the >= operator so they can overload it if necessary.
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!