Show older comments
What is the meaning of this line?
...
a = b<0;
c = 3*a;
...
Is a IF condition?
Accepted Answer
More Answers (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".
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!