主要内容

getTFMapSize

Get size of short-time Fourier transform for time-frequency labeling

Since R2026a

    Description

    sz = getTFMapSize(opts,x) gets the size of the short-time Fourier transform (STFT) of the signal x using spectrogram options opts.

    sz = getTFMapSize(opts,x,Fs) also specifies the sample rate Fs of the input signal.

    example

    Examples

    collapse all

    Generate a signal that consists of a voltage-controlled oscillator and four Gaussian atoms. The signal is sampled at 14 kHz for 2 seconds. Plot the spectrogram of the signal.

    Fs = 14000;
    t = (0:1/Fs:2)';
    gaussFun = @(A,x,mu,f) exp(-(x-mu).^2/(2*0.01^2)).*sin(2*pi*f.*x)*A';
    atoms = gaussFun([1 1 1 1]/10,t,[0.2 0.5 1 1.75],1e3*[2 6 2 5]);
    vcoIn = vco(chirp(t+.1,0,t(end),3).*exp(-2*(t-1).^2),[0.1 0.4]*Fs,Fs);
    vcoOut = vcoIn + 0.1*atoms;

    Create a set of spectrogram options for time-frequency labeling. Control the spectrogram resolution by leakage. Specify a leakage β=0.2 and overlap to 99%.

    beta = 0.2;
    opts = labelSpectrogramOptions("leakage", ...
        Leakage=40*(1-beta),Overlap=99);

    Get the size of the STFT map to be used in time-frequency labeling.

    sz = getTFMapSize(opts,vcoOut,Fs)
    sz = 1×2
    
            1024        9262
    
    

    Input Arguments

    collapse all

    Spectrogram options, specified as a labelSpectrogramOptions object.

    Example: opts = labelSpectrogramOptions("windowlength",Window="chebyshev") specifies a labelSpectrogramOptions object that stores spectrogram options for time-frequency labeling.

    Input signal, specified as a vector or MATLAB® timetable with uniformly sampled times and one variable comprising a column vector.

    Example: x = chirp(0:1e-3:1,0,0.5,100,"quadratic") specifies a quadratic swept-frequency signal.

    Example: x = timetable(seconds(0:1e-3:1)',chirp(0:1e-3:1,0,0.5,100,"quadratic")') specifies a timetable containing a quadratic swept-frequency signal.

    Data Types: single | double
    Complex Number Support: Yes

    Sample rate, specified as a positive scalar.

    • If you specify Fs, then getTFMapSize assumes that the input signal x has a sample rate of Fs Hz.

    • If you do not specify Fs or set it to empty [], then getTFMapSize uses a normalized sample rate.

    Do not specify Fs if you specify x as a timetable. The getTFMapSize function infers the sample rate from the time values specified in x.

    Output Arguments

    collapse all

    STFT size, returned as a two-element vector. The vector sz contains the number of rows and columns of the STFT matrix.

    Version History

    Introduced in R2026a