home *** CD-ROM | disk | FTP | other *** search
- function specplot(P,Fs)
- %SPECPLOT Plot the output of the SPECTRUM function.
- % SPECPLOT(P,Fs), uses P, the output of SPECTRUM, and Fs, the
- % sample frequency, to successively plot:
- %
- % Pxx - X Power Spectral Density & confidence.
- % Pyy - Y Power Spectral Density & confidence.
- % abs(Txy) - Transfer Function Magnitude.
- % angle(Txy) - Transfer Function Phase.
- % Cxy - Coherence Function.
- %
- % The 95% confidence intervals are displayed on the power
- % spectral density curves.
- %
- % SPECPLOT(P) uses normalized frequency, Fs = 2, so that 1.0 on
- % the frequency axis is half the sample rate (the Nyquist
- % frequency).
-
- % J.N. Little 7-9-86
- % Revised 11-14-91 JNL
- % Copyright (c) 1986-91 by the MathWorks, Inc.
-
- [n,m] = size(P);
- if nargin < 2
- Fs = 2;
- end
- f = (1:n-1)/n*Fs/2;
-
- if m == 2
- c = [P(2:n,1)+P(2:n,2) P(2:n,1)-P(2:n,2)];
- else
- c = [P(2:n,1)+P(2:n,6) P(2:n,1)-P(2:n,6)];
- end
- c = c .* (c > 0);
- semilogy(f,P(2:n,1),f,c(:,1),'--',f,c(:,2),'--'), ...
- title('Pxx - X Power Spectral Density'), ...
- xlabel('Frequency')
- if m == 2
- return
- end
-
- pause
-
- c = [P(2:n,2)+P(2:n,7) P(2:n,2)-P(2:n,7)];
- c = c .* (c > 0);
- semilogy(f,P(2:n,2),f,c(:,1),'--',f,c(:,2),'--'), ...
- title('Pyy - Y Power Spectral Density'), ...
- xlabel('Frequency'), pause
-
- semilogy(f,abs(P(2:n,4))), ...
- title('Txy - Transfer function magnitude'), ...
- xlabel('Frequency'), pause
-
- plot(f,180/pi*angle(P(2:n,4))), ...
- title('Txy - Transfer function phase'), ...
- xlabel('Frequency'), ...
- ylabel('Degrees'), pause
-
- plot(f,abs(P(2:n,5))), ...
- title('Cxy - Coherence'), ...
- xlabel('Frequency'), pause
-
-