Download Help (Windows Only) |

**Owning Class: **spectral analysis

**Requires: **MathScript RT Module

spectrogram(x)

spectrogram(x, win)

spectrogram(x, win, noverlap)

spectrogram(x, win, noverlap, fftsize)

spectrogram(x, win, noverlap, fftsize, fs)

[S, f] = spectrogram(x)

[S, f] = spectrogram(x, win)

[S, f] = spectrogram(x, win, noverlap)

[S, f] = spectrogram(x, win, noverlap, fftsize)

[S, w] = spectrogram(x, win, noverlap, fftsize, fs)

[S, f, t] = spectrogram(x)

[S, f, t] = spectrogram(x, win)

[S, f, t] = spectrogram(x, win, noverlap)

[S, f, t] = spectrogram(x, win, noverlap, fftsize)

[S, w, t] = spectrogram(x, win, noverlap, fftsize, fs)

[S, f, t, P] = spectrogram(x)

[S, f, t, P] = spectrogram(x, win)

[S, f, t, P] = spectrogram(x, win, noverlap)

[S, f, t, P] = spectrogram(x, win, noverlap, fftsize)

[S, w, t, P] = spectrogram(x, win, noverlap, fftsize, fs)

Legacy Name: `specgram`

Computes the signal energy distribution in the joint time-frequency domain using the Short-Time Fourier Transform (STFT) algorithm. If you do not request an output, this function plots the short-time power spectrum in the current plot window.

Name | Description |
---|---|

x |
Specifies the input time-domain signal. x is a real or complex vector. |

win |
Specifies the window to apply to each segment of x. The length of win determines the segment length into which LabVIEW divides x. win can be a vector that represents the window coefficients or an integer that represents a Hamming window with a length of win. The default is a Hamming window where LabVIEW divides x into eight sections. |

noverlap |
Specifies the number of data elements that overlap between adjacent segments of data. noverlap must be less than the length of win. The default is the length that results in an overlap of half the data elements between adjacent segments. |

fftsize |
Specifies the length of the FFT to perform on each segment of the data. The default is the next power of 2 greater than the length of each segment of x if this number is greater than 256. Otherwise, the default is 256. |

fs |
Specifies the sampling frequency of the input sequence in Hz. If you specify fs, LabVIEW returns the output frequencies in Hz. Otherwise, LabVIEW returns the output frequencies in radians per sample. |

Name | Description |
---|---|

S |
Returns a matrix that contains the Short-Time Fourier Transform (STFT) of the signal specified by the vector x. Each column of S contains the STFT of each segment of the signal x. Time increases from left to right across the columns of S. Frequency increases down the rows starting at 0. If x is real, S has (fftsize / 2 + 1) rows when fftsize is even, and (fftsize + 1) / 2 rows when fftsize is odd. Otherwise, S has fftsize rows. |

f |
Returns the frequencies in Hz at the points where LabVIEW evaluates the STFT. The length of f equals the number of rows in S. |

w |
Returns the frequencies in radians per sample at the points where LabVIEW evaluates the STFT. The length of w equals the number of rows in S. |

t |
Returns the time interval between the centers of each segment of x from the start of the x. The length of t equals the number of columns in S. |

P |
Returns a matrix that contains the power spectral density (PSD) of the signal specified by the vector x. Each column of P contains the PSD of each segment of the signal x. Time increases from left to right across the columns of P. Frequency increases down the rows starting at 0. size(P) equals size(S). |

The following table lists the support characteristics of this function.

Supported in the LabVIEW Run-Time Engine | Yes (if you request output) |

Supported on RT targets | Yes (if you request output) |

Suitable for bounded execution times on RT | Not characterized |

s = 0:0.01:8*pi;

x = sin(5*s.*s) + cos(40*s) + cos(211*s);

S = spectrogram(x, 64, 32, 128, 500);

Helpful

Not Helpful