difference between | and || in my function
Mostrar comentarios más antiguos
Hi ;
I have a code in which
function metCondition = Ambient_Temperature(vector)
metCondition = true; % Initialize
if any((vector) <= -7 | (vector) >= 37.86) %degC
metCondition = false;
end
what is the difference between
if any((vector) <= -7 | (vector) >= 37.86) %degC
and
if any((vector) <= -7 || (vector) >= 37.86) %degC
and why am i getting an error when using ||.
Thanks
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 11 de En. de 2017
You could use
if any((vector) <= -7) || any((vector) >= 37.86) %degC
|| can only be used when both sides return scalars. || is the "short circuit" OR operator -- it does not bother evaluating the right hand side of the left hand side is already true.
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!