Borrar filtros
Borrar filtros

'Or' statement in matlab?

27 visualizaciones (últimos 30 días)
Aadil
Aadil el 7 de Sept. de 2012
Editada: Simran Wasu el 20 de Feb. de 2016
How can I do this without using else if?:
if balls == 0 & ( x > 5 OR y > 7)
run xscript
end
Thanks,
  4 comentarios
José-Luis
José-Luis el 7 de Sept. de 2012
Image Analyst understood faster and gave you the answer...
Simran Wasu
Simran Wasu el 20 de Feb. de 2016
Editada: Simran Wasu el 20 de Feb. de 2016
use '||' for OR command (without quotes).

Iniciar sesión para comentar.

Respuesta aceptada

Image Analyst
Image Analyst el 7 de Sept. de 2012
Editada: Image Analyst el 7 de Sept. de 2012
You need two &&:
if balls == 0 && ( x > 5 || y > 7)
% run xscript
xscript();
end
  5 comentarios
Image Analyst
Image Analyst el 7 de Sept. de 2012
I've seen that before - where the vertical lines don't appear. However I can't reproduce anymore. For me | appears both in regular text, and code formatted text. By the way, I edited by answer to change "run xscript" to be just "xscript" since the "run" command like you had is not needed.
Aadil
Aadil el 7 de Sept. de 2012
ok thanks everyone

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by