home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l455 / 8.ddi / SIGNAL.DI$ / XCOV.M < prev    next >
Encoding:
Text File  |  1993-03-11  |  1.9 KB  |  49 lines

  1. function xycov = xcov(x,y,option)
  2. %XCOV    Cross-covariance function estimates.
  3. %    The cross-covariance is the cross-correlation function of
  4. %    two sequences with their means removed.
  5. %    XCOV(A,B), where A and B are length M vectors, returns the
  6. %    length 2*M-1 cross-covariance sequence in a column vector.
  7. %    XCOV(A), when A is a vector, is the auto-covariance sequence.
  8. %    XCOV(A), when A is an M-by-N matrix, is a large matrix with
  9. %    2*M-1 rows whose N^2 columns contain the cross-covariance
  10. %    sequences for all combinations of the columns of A.
  11. %    The zeroth lag of the output covariance is in the middle of the 
  12. %    sequence, at element or row M.
  13. %    By default, XCOV computes a raw covariance with no normalization.
  14. %    XCOV(A,'biased') or XCOV(A,B,'biased) returns the "biased"
  15. %    estimate of the cross-covariance function.  The biased estimate
  16. %    scales the raw cross-covariance by 1/M.
  17. %    XCOV(...,'unbiased') returns the "unbiased" estimate of the
  18. %    cross-covariance function.  The unbiased estimate scales the raw
  19. %    covariance by 1/(M-abs(k)), where k is the index into the result.
  20. %    XCOV(...,'coeff') normalizes the sequence so that the
  21. %    covariances at zero lag are identically 1.0.
  22. %    See also XCORR, CORRCOEF, CONV and XCORR2.
  23.  
  24. %    L. Shure 1-9-88
  25. %    Copyright (c) 1988 by the MathWorks, Inc.
  26.  
  27. %    References:
  28. %      [1] J.S. Bendat and A.G. Piersol, "Random Data:
  29. %          Analysis and Measurement Procedures", John Wiley
  30. %          and Sons, 1971, p.332.
  31. %      [2] A.V. Oppenheim and R.W. Schafer, Digital Signal 
  32. %          Processing, Prentice-Hall, 1975, pg 539.
  33.  
  34. [mx,nx] = size(x);
  35. if nargin == 1
  36.     xycov = xcorr(x-ones(mx,1)*mean(x));
  37. elseif nargin == 2
  38.     if isstr(y)
  39.         xycov = xcorr(x-ones(mx,1)*mean(x),y);
  40.     else
  41.         [my,ny] = size(y);
  42.         xycov = xcorr(x-ones(mx,1)*mean(x),y-ones(my,1)*mean(y));
  43.     end
  44. else
  45.     [my,ny] = size(y);
  46.     xycov = xcorr(x-ones(mx,1)*mean(x),y-ones(my,1)*mean(y),option);
  47. end
  48.  
  49.