if statement with conditions a and (b or c)
73 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
AA
am 21 Feb. 2015
Bearbeitet: John D'Errico
am 21 Feb. 2015
Hi guys, how can I use the if condition if i want the follow
if A and (b or c)
how can i translate this as a code???
0 Kommentare
Akzeptierte Antwort
John D'Errico
am 21 Feb. 2015
Bearbeitet: John D'Errico
am 21 Feb. 2015
Use the && operator for and, and use the operator to do the or part. So your statement looks like this:
if A && (b || c)
stuff
end
Do not use & and | for those tests, as && and are designed to work explicitly and optimally in if statements. They allow the tests to be short-circuited, so that if the entire test is known to be true or false, the remainder of the tests are not performed, thus saving CPU cycles.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dynamic System Models finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!