if elseif function not working properly

2 visualizaciones (últimos 30 días)
David Phung
David Phung el 26 de Oct. de 2014
Comentada: David Phung el 26 de Oct. de 2014
Hey, this is my code and it doesnt work if I try to get something in the 3rd or 4th quadrant. Can someone tell me where my mistake is?
function [ romannum ] = quadrant( x,y )
if x>0, y>0
fprintf('Input coordinates will be in quadrant I. \n')
elseif x<0,y>0
fprintf('Input coordinates will be in quadrant II. \n')
elseif x<0,y<0
fprintf('Input coordinates will be in quadrant III. \n')
elseif x>0, y<0
fprintf('Input coordinates will be in quadrant IV. \n')
end
end

Respuesta aceptada

the cyclist
the cyclist el 26 de Oct. de 2014
This syntax
if x>0, y>0
is wrong. It should be
if x>0 & y>0
assuming you mean "and".
  1 comentario
David Phung
David Phung el 26 de Oct. de 2014
Thank you so much! I cant believe I overlooked that.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by