home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 9.ddi / IDENT.DI$ / PHASE.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  516 b   |  24 lines

  1. function PHI=phase(G)
  2. %PHASE  Computes the phase of a complex vector
  3. %
  4. %    PHI=phase(G)
  5. %
  6. %    G is a complex-valued row vector and PHI is returned as its
  7. %    phase (in radians), with an effort made to keep it continuous
  8. %    over the pi-borders.
  9.  
  10. %    L. Ljung 10-2-86
  11. %    Copyright (c) 1986-90 by the MathWorks, Inc.
  12. %    All Rights Reserved.
  13.  
  14. PHI=atan2(imag(G),real(G));
  15. N=length(PHI);
  16. DF=PHI(1:N-1)-PHI(2:N);
  17. I=find(abs(DF)>3.5);
  18. for i=I
  19. if i~=0,
  20. PHI=PHI+2*pi*sign(DF(i))*[zeros(1,i) ones(1,N-i)];
  21. end
  22. end
  23.  
  24.