Main Content

scaleSpectrum

Scale-averaged wavelet spectrum

    Description

    example

    savgp= scaleSpectrum(fb,x)returns the scale-averaged wavelet power spectrum of the signalxusing the CWT filter bankfb. By default,savgpis obtained by scale-averaging the magnitude-squared scalogram over all scales.

    savgp= scaleSpectrum(fb,cfs)returns the scale-averaged wavelet spectrum for the CWT coefficientscfs.

    Note

    When using this syntax, the power of the scale-averaged wavelet spectrum is normalized to equal the variance of the last signal processed by the filter bank object functionwt.

    [savgp,scidx] = scaleSpectrum(___)also returns the scale indices over which the scale-averaged wavelet spectrum is computed. If you do not specifyFrequencyLimitsorPeriodLimits,scidxis a vector from 1 to the number of scales.

    example

    [___] = scaleSpectrum(___,Name,Value)specifies additional options using name-value pair arguments. These arguments can be added to any of the previous input syntaxes. For example,'Normalization','none'specifies no normalization of the scale-averaged wavelet spectrum.

    scaleSpectrum(___)with no output arguments plots the scale-averaged wavelet power spectrum in the current figure.

    Examples

    崩溃all

    Load an audio file containing a fragment of Handel's "Hallelujah Chorus" sampled at 8192 Hz.

    loadhandel% To hear, type soundsc(y,Fs)

    Create a CWT filter bank that can be applied to the signal. Use the default Morse wavelet.

    fb = cwtfilterbank ('SignalLength',length(y),'SamplingFrequency',Fs);

    Plot the scalogram and scale-averaged wavelet power spectrum using the default settings.

    scaleSpectrum(fb,y)

    Figure contains 2 axes objects. Axes object 1 with title Magnitude Scalogram contains 3 objects of type image, line, area. Axes object 2 with title Scale-Averaged Wavelet Spectrum contains an object of type line.

    Load a time series of solar magnetic field magnitudes recorded hourly over the south pole of the sun by the Ulysses spacecraft from 21:00 UT on December 4, 1993 to 12:00 UT on May 24, 1994. See[2]pp. 218–220 for a complete description of this data. Create a CWT filter bank that can be applied to the data. Plot the scalogram and the scale-averaged wavelet spectrum.

    loadsolarMFmagnitudesfb = cwtfilterbank ('SignalLength',length(sm),'SamplingPeriod',hours(1)); scaleSpectrum(fb,sm)

    Figure contains 2 axes objects. Axes object 1 with title Magnitude Scalogram contains 3 objects of type image, line, area. Axes object 2 with title Scale-Averaged Wavelet Spectrum contains an object of type line.

    Obtain the scale-averaged wavelet spectrum of the signal using default values. By default,scaleSpectrumnormalizes the power of the scale-averaged wavelet spectrum to equal the variance of the signal. Verify that the sum of the spectrum equals the variance of the signal.

    savg = scaleSpectrum(fb,sm); [var(sm) sum(savg)]
    ans =1×20.0448 0.0447

    Obtain the scale-averaged wavelet spectrum of the signal, but instead normalize the power as a probability density function. Verify that the sum is equal to 1.

    savg = scaleSpectrum(fb,sm,'Normalization','pdf'); sum(savg)
    ans = 1.0000

    如果you setSpectrumTypeto'density',scaleSpectrumnormalizes the weighted integral of the wavelet spectrum according to the value ofNormalization. In this case, the spectrum mimics a probability density function whose integral, numerically evaluated, equals the value specified byNormalization.

    Plot the scalogram and the scale-averaged wavelet spectrum with spectrum type'density'and'pdf'normalization.

    figure scaleSpectrum(fb,sm,'SpectrumType','density','Normalization','pdf')

    Figure contains 2 axes objects. Axes object 1 with title Magnitude Scalogram contains 3 objects of type image, line, area. Axes object 2 with title Scale-Averaged Wavelet Spectrum contains an object of type line.

    To confirm the integral of the spectrum equals 1, first obtain the scale-averaged wavelet spectrum with'density'spectrum type and'pdf'normalization.

    savg = scaleSpectrum(fb,sm,'SpectrumType','density','Normalization','pdf');

    By default, the filter bank uses the analytic Morse (3,60) wavelet. Obtain the admissibility constant for the wavelet and numerically integrate the wavelet spectrum using the trapezoidal rule. Confirm that the integral equals 1.

    ga = 3; tbw = 60; be = tbw/ga; anorm = 2*exp(be/ga*(1+(log(ga)-log(be)))); cPsi = anorm^2/(2*ga).*(1/2)^(2*(be/ga)-1)*gamma(2*be/ga); numInt = 2/cPsi*1/length(sm)*trapz(1:length(savg),savg)
    numInt = 1.0000

    Input Arguments

    崩溃all

    Continuous wavelet transform (CWT) filter bank, specified as acwtfilterbankobject.

    Input data, specified as a real- or complex-valued vector. The input dataxmust have at least four samples.

    数据类型:single|double
    Complex Number Support:Yes

    CWT coefficients, specified as a 2-D matrix or as anM-by-N-by-2 array.cfsshould be the output of thewtobject function of the CWT filter bankfb.

    数据类型:single|double
    Complex Number Support:Yes

    Name-Value Arguments

    Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, whereNameis the argument name andValueis the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

    Before R2021a, use commas to separate each name and value, and encloseNamein quotes.

    Example:scaleSpectrum(fb,x,'FrequencyLimits',[0.2 0.4])returns the scale-averaged wavelet spectrum averaged over the frequency limits[0.2 0.4].

    Normalization of the scale-averaged wavelet spectrum, specified as a comma-separated pair consisting of'Normalization'and one of the following:

    • 'var'— Normalize to equal the variance of the time seriesx. If you provide thecfsinput, thescaleSpectrumfunction uses the variance of the last time series processed by the filter bank object functionwt.

    • 'pdf'— Normalize to equal 1.

    • 'none'— No normalization is applied.

    Type of wavelet spectrum to return, specified as a comma-separated pair consisting of'SpectrumType'and either'power'or'density'. If specified as'power', the averaged sum of the scale-averaged wavelet spectrum over all scales is normalized according to the value specified in 'Normalization”。如果specified as'density', the weighted integral of the wavelet spectrum over all scales is normalized according to the value specified in 'Normalization”。

    Frequency limits over which the magnitude-squared scalogram is averaged, specified as a comma-separated pair consisting of'FrequencyLimits'and a two-element vector with nondecreasing elements. TheFrequencyLimitsvalues must lie between the lowest and highest center frequencies returned by thecenterFrequenciesobject function offb. The base 2 logarithm of the ratio of the maximum frequency to the minimum frequency must be greater than or equal to 1/NV, whereNVis the value of the 'VoicesPerOctave' property of the filter bankfb.

    如果a region of the specified limits falls outside the frequency limits of the filter bankfb,scaleSpectrumtruncates computations to within the range specified bycenterFrequencies(fb).FrequencyLimitscannot be completely outside of the Nyquist range.

    Period limits over which the magnitude-squared scalogram is averaged, specified as a comma-separated pair consisting of'PeriodsLimits'and a two-element vector with nondecreasing durations. The elements ofPeriodLimitsagree in type and format with the 'SamplingPeriod' property of the filter bankfb. TheSamplingPeriodvalues must lie between the lowest and highest center periods returned by thecenterPeriodsobject function offb. The base 2 logarithm of the ratio of the minimum period to the maximum period must be less than or equal to -1/NV, whereNVis the value of the 'VoicesPerOctave' property of the filter bankfb.

    如果a region of the specified limits falls outside the period limits of the filter bankfb,scaleSpectrumtruncates computations to within the range specified bycenterPeriods(fb).SamplingPeriodcannot be completely outside the Nyquist range of [2*Ts,N*Ts], whereTsis the 'SamplingPeriod' andNis the signal length.

    Output Arguments

    崩溃all

    Scale-averaged wavelet power spectrum, returned as a real-valued vector or real-valued 3-D array. Ifxis real-valued,savgpis a 1-by-Nvector whereNis the length ofx. Ifxis complex-valued,savgpis a 1-by-N-by-2 array, where the first page is the scale-averaged wavelet spectrum for the positive scales (analytic part or counterclockwise component), and the second page is the scale-averaged wavelet spectrum for the negative scales (anti-analytic part or clockwise component).

    Scale indices over which the scale-average wavelet spectrum is computed, returned as a vector. If you do not specify 'FrequencyLimits' or 'PeriodLimits',scidxis a vector from 1 to the number of scales.

    References

    [1] Torrence, Christopher, and Gilbert P. Compo. “A Practical Guide to Wavelet Analysis.”Bulletin of the American Meteorological Society79, no. 1 (January 1, 1998): 61–78. https://doi.org/10.1175/1520-0477(1998)079<0061:APGTWA>2.0.CO;2.

    [2] Percival, Donald B., and Andrew T. Walden.小波时间序列分析的方法. Cambridge Series in Statistical and Probabilistic Mathematics. Cambridge ; New York: Cambridge University Press, 2000.

    [3] Lilly, J.M., and S.C. Olhede. “Higher-Order Properties of Analytic Wavelets.” IEEE Transactions on Signal Processing 57, no. 1 (January 2009): 146–60. https://doi.org/10.1109/TSP.2008.2007607.

    Extended Capabilities

    Version History

    Introduced in R2020b