'Or' statement in matlab?
    4 views (last 30 days)
  
       Show older comments
    
How can I do this without using else if?:
if balls == 0 & ( x > 5 OR y > 7)
    run xscript
end
Thanks,
4 Comments
  Simran Wasu
 on 20 Feb 2016
				
      Edited: Simran Wasu
 on 20 Feb 2016
  
			use '||' for OR command (without quotes).
Accepted Answer
  Image Analyst
      
      
 on 7 Sep 2012
        
      Edited: Image Analyst
      
      
 on 7 Sep 2012
  
      You need two &&:
if balls == 0 && ( x > 5 || y > 7)
    % run xscript
    xscript();
end
5 Comments
  Image Analyst
      
      
 on 7 Sep 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.
More Answers (0)
See Also
Categories
				Find more on Get Started with MATLAB 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!