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

  1. function specplot(P,Fs)
  2. %SPECPLOT Plot the output of the SPECTRUM function.
  3. %    SPECPLOT(P,Fs), uses P, the output of SPECTRUM, and Fs, the
  4. %    sample frequency, to successively plot:
  5. %
  6. %        Pxx - X Power Spectral Density & confidence.
  7. %        Pyy - Y Power Spectral Density & confidence.
  8. %        abs(Txy) - Transfer Function Magnitude.
  9. %        angle(Txy) - Transfer Function Phase.
  10. %        Cxy - Coherence Function.
  11. %
  12. %    The 95% confidence intervals are displayed on the power
  13. %    spectral density curves.
  14. %
  15. %    SPECPLOT(P) uses normalized frequency, Fs = 2, so that 1.0 on
  16. %    the frequency axis is half the sample rate (the Nyquist 
  17. %    frequency).
  18.  
  19. %    J.N. Little 7-9-86
  20. %    Revised 11-14-91 JNL
  21. %    Copyright (c) 1986-91 by the MathWorks, Inc.
  22.  
  23. [n,m] = size(P);
  24. if nargin < 2
  25.    Fs = 2;
  26. end
  27. f = (1:n-1)/n*Fs/2;
  28.  
  29. if m == 2
  30.    c = [P(2:n,1)+P(2:n,2) P(2:n,1)-P(2:n,2)];
  31.   else
  32.    c = [P(2:n,1)+P(2:n,6) P(2:n,1)-P(2:n,6)];
  33. end
  34. c = c .* (c > 0);
  35. semilogy(f,P(2:n,1),f,c(:,1),'--',f,c(:,2),'--'), ...
  36. title('Pxx - X Power Spectral Density'), ...
  37. xlabel('Frequency')
  38. if m == 2
  39.    return
  40. end
  41.  
  42. pause
  43.  
  44. c = [P(2:n,2)+P(2:n,7) P(2:n,2)-P(2:n,7)];
  45. c = c .* (c > 0);
  46. semilogy(f,P(2:n,2),f,c(:,1),'--',f,c(:,2),'--'), ...
  47.  title('Pyy - Y Power Spectral Density'), ...
  48.  xlabel('Frequency'), pause
  49.  
  50. semilogy(f,abs(P(2:n,4))), ...
  51.  title('Txy - Transfer function magnitude'), ...
  52.  xlabel('Frequency'), pause
  53.  
  54. plot(f,180/pi*angle(P(2:n,4))), ...
  55.  title('Txy - Transfer function phase'), ...
  56.  xlabel('Frequency'), ...
  57.  ylabel('Degrees'), pause
  58.  
  59. plot(f,abs(P(2:n,5))), ...
  60.  title('Cxy - Coherence'), ...
  61.  xlabel('Frequency'), pause
  62.  
  63.