Home > NoiseTools > nt_spect_plot.m

# nt_spect_plot

## PURPOSE

nt_spect_plot - plot power spectrum

## SYNOPSIS

function varargout=nt_spect_plot(x,varargin)

## DESCRIPTION

    nt_spect_plot - plot power spectrum

      The power spectral densities of all columns (pages, etc.) are calculated
      and added.  The result is divided by the number of columns and either
      plotted or returned.

     See pwelch for syntax.

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- nt_bias_cluster [c0,c1,A,todss,pwr0,pwr1]=nt_bias_cluster(x,dsr,flags) - cluster covariance
- nt_cluster_jd [IDX,todss,SCORE,COVS]=nt_cluster_jd(x,dsr,smooth,flags,init,verbose) - cluster with joint diagonalization
- nt_spect_plot2 nt_spect_plot2 - plot power spectrum
- nt_zapline [y,yy]=nt_zapline(x,fline,nremove,p,plotflag) - remove power line artifact

## SOURCE CODE

    0001 function varargout=nt_spect_plot(x,varargin)
    0002 %nt_spect_plot - plot power spectrum
    0003 %
    0004 %  The power spectral densities of all columns (pages, etc.) are calculated
    0005 %  and added.  The result is divided by the number of columns and either
    0006 %  plotted or returned.
    0007 %
    0008 % See pwelch for syntax.
    0009
    0010 if numel(x)==0; error('!'); end
    0011
    0012 N=numel(x);
    0013 ncols=N/size(x,1);
    0014 x=reshape(x,size(x,1),ncols);
    0015
    0016 [pxx,f]=pwelch(x(:,1),varargin{:});
    0017
    0018 for k=1:ncols
    0019     [a,b]=pwelch(x(:,k),varargin{:});
    0020     pxx=pxx+a;
    0021 end
    0022 pxx=pxx/ncols;
    0023
    0024
    0025 if nargout == 0;
    0026     plot(f,abs(pxx).^0.5);
    0027     set(gca,'yscale','log');
    0028     xlim([f(1) f(end)]);
    0029     xlabel('Hz'); ylabel('Hz^{-0.5}', 'interpreter', 'tex');
    0030     varargout={};
    0031 else
    0032     varargout={pxx,f};
    0033 end