MATLAB: When use || and | in if

if statement

Hello,
when can I use and | in command if?
For example:
if a||b
if a| b
Thank you

Best Answer

a||b will return 1 if the first expression a is true, without evaluating the second expression b
Example
2==2 || hhh % even hhh is not defined Matlab will not evaluate it, because the first expression 2==2 is true
a&&b will return 0 if the first expression a is false without evaluating the second expression b