MATLAB: Changing the atan function so that it ranges from 0 to 2*pi

functionlive scriptMATLABrange

I know that the matlab atan function returns values in the range of -pi/2 to pi/2. How do i change it so that it goes over the full range 0 to 2*pi?
My first attempt was using a while loop, but it was incorrect.
I need to write a function mfile to set the built-in matlab function atan in the range of 0 to 2*pi without using atan2. im new to matlab so im unsure of what to do.
Thank you

Best Answer

Adding mod 2*pi to atan2 should work just fine
shit = mod(atan2(y,x),2*pi);