Documentation of 'spectrum' function from Matlab 5.x releases?
9 views (last 30 days)
Show older comments
Hi everyone,
I am upgrading some very old code that I inherited. The function comments indicate that code was originally written between 1994, with bug fixes and other modifications through 1996. Thus, I believe the code was originally developed for Matlab version 5.x.
At one point, the code calls the function 'spectrum', in functional form. Specifically:
P=spectrum(Signal1,Signal2,FFT_LENGTH);
(I have replaced the actual variable names with Signal1 and Signal2 to make the arguments more clear.)
When I run this line, my version of Matlab (2010a) gives the warning:
Warning: SPECTRUM is obsolete and will be removed in future versions.
Use the spectrum objects instead, type "help SPECTRUM".
However, according to Mathworks, "SPECTRUM function is obsolete starting Signal Processing Toolbox 6.7 (R2007a). The result provided by SPECTRUM function does not have the proper scaling due to, for example, the sampling frequency. That could be the reason for the 30dB difference." (source: http://www.mathworks.com/support/solutions/en/data/1-6D05QY/index.html?product=ML&solution=1-6D05QY).
Thus, to do the upgrade, I need to be able to replace the call to spectrum in the old code with the newer spectrum objects. However, I cannot locate documentation for the old implementation of spectrum, to determine how to make equivalents. The oldest documentation on Mathworks' site is R13SP2, which does not appear to even contain the 'spectrum' function, and all newer documentation versions on the site appear to document only the newer object form of spectrum.
Does anyone have any advice? Does Mathworks provide older documentation like this?
0 Comments
Accepted Answer
Wayne King
on 10 Jul 2012
This actually produces 8 outputs
P = spectrum(signal1,signal2,NFFT);
In other words, P is a Nx8 matrix. The first column is the power spectral density of signal1 using a Welch estimate.
You can get that with pwelch
The second column is a power spectral density of signal2 using a Welch estimate. (again pwelch)
The 3rd column is the cross spectral density of x and y. You can use cpsd()
The 4th column is transfer function estimate -- you can use tfestimate.m
The 5th column is the magnitude-squared coherence. You can use mscohere.m
The last three are confidence intervals for column 1, column 2, and column3.
3 Comments
Wayne King
on 11 Jul 2012
The scaling on pwelch is more consistent with the definition of a power spectral density. Theoretically, the power spectral density is the Fourier transform of the autocorrelation. If you follow through on the theory using a biased estimate of the autocorrelation, you'll get the scaling used with the new MATLAB routines -- periodogram, pwelch, etc.
More Answers (0)
See Also
Categories
Find more on Spectral Estimation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!