MATLAB: Problem with if statement

atan2if

Hi Guys,
This is a very basic question. I want to figure out which quadrant a point lies in from the value I get from atan2. I dont know if there is a simpler way but I wrote a code containing a series of if statements and it isnt executing right. Can anyone tell me what is wrong in it. Your help is greatly appreciated.
if 0<ang<1.5708
quad=1;
end
if 1.5708<ang<3.1416
quad=2;
end
if -1.5708<ang<0
quad=3;
end
if -3.1416<ang<-1.5708
quad=4;
end
Thanks, NS

Best Answer

if (0<ang && ang <1.5708)
quad=1;
elseif (1.5708<ang && ang<3.1416)
quad=2;
elseif (-1.5708<ang && ang<0)
quad=3;
else
quad=4;
end
You can't do 0<ang<pi/2