function handle = plotphase1(X,points,jcount,start,Qdata,varargin)

if nargin==6,
    LW = varargin{1};
else
    LW = 2;
end

for j=1:jcount,
    
    k = start;  % specify amount of phase shift for first point
    imark = i;

    for i=1:points,
        W(i) = 180*angle(Qdata(i,j)) / pi;
        
        % if phase of first point is >0, then subtract 360
        if i==1 
            if W(i)>0
                k=k+1;
            end
        end
        
        % if phase >160 and was <=160 then subtract 360
      
        if (i>1) & (W(i)>160)
            if W(i-1)<=-160
                k=k+1; imark = [imark i];
            end
        end
        
% not sure why the following was included. 
% Removed 23/07/02 and replaced with test below

%        % if phase difference from prevous point <-270, add 360
%      
%        if (i>1)
%            if W(i)-W(i-1)<-270
%                k=k-1; ark = [imark i];
%            end
%        end


        % if phase <-160 and was >=160 then add 360
      
        if (i>1) & (W(i)<-160)
            if W(i-1)>=160
                k=k-1; imark = [imark i];
            end
        end
        

        W1(i) = W(i) - k*360;
      
    end
   
   handle = plot(X,W1,'k-','linewidth',LW);
   % or use 'k.' for dots
   % hold on
   % plot(X(imark),W1(imark),'r.','markersize',12);
   
end
