sorts the input by angle [0 2*Pi] INPUT in input to sort OUTPUT out sorted $Id: sortangle.m,v 1.1 2004/05/12 16:22:59 dalai Exp $
0001 % sorts the input by angle [0 2*Pi] 0002 % 0003 % INPUT 0004 % in input to sort 0005 % 0006 % OUTPUT 0007 % out sorted 0008 % 0009 % 0010 % $Id: sortangle.m,v 1.1 2004/05/12 16:22:59 dalai Exp $ 0011 0012 function out = sortangle(in) 0013 0014 [theta,radius]=cart2pol(real(in),imag(in)); 0015 [theta,idx]=sort(mod(theta,2*pi)); 0016 radius=radius(idx); 0017 [x,y]=pol2cart(theta,radius); 0018 out = x+i*y;