3.66667

3.7 | 3 ratings Rate this file 166 downloads (last 30 days) File Size: 6.43 KB File ID: #11689

spectral

by alex sanchez

 

12 Jul 2006 (Updated 13 Jul 2006)

No BSD License  

Spectrum using periodogram method

Download Now | Watch this File

File Information
Description

Spectrum using periodogram method

USAGE:
  q = spectral(x,dt,win,Wn,ftype,n)
  [psdf,f] = spectral(x,dt,win,Wn,ftype,n)
  [psdf,psdfc,f] = spectral(x,dt,win,Wn,ftype,n)

DESCRIPTION:
  Calculates the spectrum for x
  using the periodogram method
  If a window other than boxcar is used
  than the method is refered to as modified
  periodogram method.
  The confidence intervals are calculated
  using the inverse of chi-square CDF.
  Also includes a filtering option using the
  butterworth filter to see the effect of the
  filter on the spectrum

INPUT VARIABLES:
  x - Time series, [vector]
  dt - Sampling Rate, [scalar]
  win - Window, one of:
      'hanning', 'hamming', 'boxcar'
  Nb - Band Averaging, number of bands to average
  P - Probability for confidence intervals
  Wn - Cut-Off frequencies, used for filtering
  ftype - Type of filter, 'high', 'low' or 'stop'
  ncb - Number of coefficients to use in
      the Butterworth filter

OUTPUT VARIABLES:
  q - structure with the following fields:
      xp - detrended x
      f = Frequencies
      T - Periods
      m - Magnitude
      a - Amplitude
      s - Power spectrum, Sxx(win), [Power]
      psdw - Power Spectral Density, Pxx(win), [Power/rad/sample]
      psdf - Power Spectral Density, Pxx(f), [Power/sample-freq]
      psdT - Power Spectral Density, Pxx(T), [Power*time-unit]
      conf - Upper and Lower Confidence Interval multiplication
              factors using chi-squared approach

Acknowledgements
This submission has inspired the following:
Calibrated Spectral Analysis
MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
17 Jul 2006 Sam K

Nicely written code, seems to be very good utility.
I got the below error. What could be the fix for this?

??? Undefined command/function 'chi2inv'.

Error in ==> spectral at 180
conf = v./chi2inv([alpha2,1-alpha2],v);

Thank you.

19 Dec 2006 Nando Rosales

SAM: Needs the stata and signal toolbox. ALEX: could you improve a little bit the comments, and Bibliographic Reference

30 May 2007 andrew lee  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
spectral analysis alex sanchez 22 Oct 2008 08:32:31
period spectrum alex sanchez 22 Oct 2008 08:32:31
periodogram method alex sanchez 22 Oct 2008 08:32:31
signal process alex sanchez 22 Oct 2008 08:32:31
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com