Mostra commenti meno recenti
What is the meaning of this line?
...
a = b<0;
c = 3*a;
...
Is a IF condition?
Risposta accettata
Più risposte (1)
"a" is a logical variable.
It is set to "true" (=1) if b<0, else it is set to "false" (=0).
The next operation c = 3*a works as if "a" was a double variable.
Thus c = 3*1 = 3 if "a" was "true", else c = 3*0 = 0 if "a" was "false".
Categorie
Scopri di più su Operators and Elementary Operations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!