Having two logical operators in one for statement
古いコメントを表示
I am trying to check if three logical statements are true in order to proceed with the for statement, otherwise the function would return 0. Does this work and if not how should I proceed?
if abs(p(i)) > sigma_d && -p(i) <= 0 && d(i) > 0
ddot = -A1*(abs(p(i))/sigma_d - 1);
else
ddot = 0;
end
1 件のコメント
Walter Roberson
2024 年 10 月 21 日
&& -p(i) <= 0
as a matter of form, I recommend the test
&& p(i) >= 0
The negative logic is unnecessarily confusing.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!