Main Content

getFrequencyVector

Get the vector of frequencies at which the short-time FFT is computed

Since R2020b

Description

example

freq = getFrequencyVector(stf) returns the frequency vector at which the short-time FFT is computed. The input sample rate used is 2π.

example

freq = getFrequencyVector(stf,Fs) returns the frequency vector assuming an input sample rate, Fs.

Examples

collapse all

Get the frequency vector at which the short-time FFT is computed.

Create a dsp.STFT object. The STFT object is defined with a 'twosided' frequency range. The frequency vector is defined by the interval [0 Fs] and has the same length as the FFT length, where Fs is the input sample rate.

stf = dsp.STFT
stf = 
  STFT with properties:

            Window: [512x1 double]
     OverlapLength: 256
         FFTLength: 512
    FrequencyRange: 'twosided'

When the input sample rate Fs is not defined, the frequencies are computed in the interval [0, 2π].

Using the getFrequencyVector function, get the vector of frequencies at which the STFT is computed.

freq = getFrequencyVector(stf)
freq = 512×1

         0
    0.0123
    0.0245
    0.0368
    0.0491
    0.0614
    0.0736
    0.0859
    0.0982
    0.1104
      ⋮

When the input sample rate Fs is defined, the frequency vector is defined by the interval [0 Fs].

Fs = 44100;
freqFs = getFrequencyVector(stf,Fs)
freqFs = 512×1
104 ×

         0
    0.0086
    0.0172
    0.0258
    0.0345
    0.0431
    0.0517
    0.0603
    0.0689
    0.0775
      ⋮

Input Arguments

collapse all

Short-time FFT object whose frequency vector is computed, specified as dsp.STFT object.

Input sample rate, specified as a real positive scalar. The STFT frequencies are computed in the interval determined by Fs. For more details, see freq.

Data Types: single | double

Output Arguments

collapse all

Frequencies at which the short-time FFT is computed, returned as a column vector.

The length of the frequency vector is determined by the FrequencyRange property and the FFTLength.

If you set FrequencyRange to 'onesided' and FFTlength is even, the frequency vector is of length (FFTlength/2)+1. If you set the FrequencyRange to 'onesided' and FFTlength is odd, the frequency vector is of length (FFTlength+1)/2.

The frequencies cover the interval [0, Fs/2]. When Fs is not specified, the frequencies range from [0, π].

If you set the FrequencyRange property to 'twosided', the length of the frequency vector is equal to the value you specify in the FFTlength property. The frequencies cover the interval [0, Fs]. When Fs is not specified, the frequencies range from [0, 2π].

Data Types: single | double

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2020b

See Also