function labs=deglabels(tiks,latlonflag);

% labs=deglabels(tiks,latlonflag);
%
% produce labels "labs" for degree tick marks "tiks".
% The labels will always be positive, with
% a degree sign after the number.
% set latlonflag=1 for N/S; 2 for E/W, 0 or empty for ""

tiks2=tiks;
while (min(tiks2)<-180 | max(tiks2)>180);
    q=find(tiks2<-180); tiks2(q)=tiks2(q)+360;
    q=find(tiks2>180); tiks2(q)=tiks2(q)-360;
end;
tiks=tiks2;
if (size(tiks,1)>size(tiks,2))
  labs=num2str(abs(tiks2));
else
  labs=num2str(abs(tiks2'));
end;
if ~exist('latlonflag')
    latlonflag=0;
end;

labs=[labs,ones(length(tiks),1)*setstr(176)];
if (latlonflag)
    labs=[labs,ones(length(tiks),1)*' '];
    if (latlonflag==1)
        q=find(tiks<0);
        labs(q,size(labs,2))='S';
        q=find(tiks>0);
        labs(q,size(labs,2))='N';
    else
        q=find(tiks<0 | tiks>180);
        labs(q,size(labs,2))='W';
        q=find(tiks>0 & tiks<180);
        labs(q,size(labs,2))='E';
    end;
end;
        
