spectrogram function for short-time Fourier analysis

Source: Internet
Author: User
Tags local time scalar

Previously thought that the time-frequency analysis of the function is in the tool-frequency analysis toolbox, and MATLAB has not brought this toolbox, use need to download, about how to use, before written a blog see http://blog.sina.com.cn/s/blog_6163bdeb0102dvwr.html

Today dolls found the original MATLAB with a short-time Fourier transform analysis function, the old version of MATLAB is the Specgram function, the new change into the Spectrogram function, although a time-frequency analysis, will be talking about wavelet analysis, wavelet analysis than short-time Fourier is better, But in the analysis of the instantaneous spectrum of the signal, short-time Fourier still has its useful. A while ago also read some about the wavelet analysis of the MATLAB implementation, found that the use of wavelet in Help is also more noise, compression, said the wavelet is the time-frequency microscope, its use or to see the high-frequency in which level decomposition, and then can effectively filter out some of the signals, such as noise removal, So the short-time Fourier transform to see the instantaneous frequency is just complementary. Time-frequency analysis also know not deep, a stage of the idea just.

In addition, the frequency sweep function chirp of Matlab has been summarized, see Http://blog.sina.com.cn/s/blog_ 6163bdeb0100qbqo.html, inside is to use the Spectrogram function to see the frequency of the generated sweep signal instantaneous, at that time do not know what the function is dry, it feels good magic, now just see, summed up it.

spectrogram

Function: The spectrum diagram of the signal is obtained by using the short-time Fourier transform.

Grammar:

[S,f,t,p]=spectrogram (X,WINDOW,NOVERLAP,NFFT,FS)

[S,f,t,p]=spectrogram (X,WINDOW,NOVERLAP,F,FS)

Note: When the output parameter is not used, the spectrogram will be drawn automatically, and the output parameter will return the short-time Fourier transform of the input signal.

Change. Of course, you can also draw the spectrogram from the function's return value s,f,t,p, see example.

Parameters:

x---The vector of the input signal. By default, there is no subsequent input parameter, and X will be divided into 8 segments to do the transformation processing,

If x cannot be flattened into 8 segments, truncation is done. By default, the default value for other parameters is

Window---window function, default is NFFT length of the Hamming window Hamming

Noverlap---The number of overlapping samples per segment, the default value is 50% overlap between segments

Nfft---The length of the FFT transformation, the default is 256 and the maximum value is greater than the minimum 2 power of each length of time.

In addition, this parameter allows you to specify a frequency vector F, in addition to using a constant

FS---sampling frequency, default normalized frequency

Window---window function, if window is an integer, X will be divided into window segment, each section uses Hamming window function Plus window.

If window is a vector, X is divided into length (window) segments, each of which is specified using the window vector.

window function Plus window. So if you want to get the function of the Specgram function, just specify a 256-length Hann window.

Noverlap---The number of sample points that overlap between segments. It must be an integer that is less than window or length (window).

It means that two adjacent windows are not tails, but there are overlapping parts of two windows.

Nfft---Calculates the number of points of the discrete Fourier transform. It needs to be scalar.

Fs---Sampling frequency Hz, which, if specified as [], defaults to 1Hz.

S---The short-time Fourier transform of the input signal x. Each of its columns contains an estimate of the frequency component of a short-term local time,

The time increases along the column and the frequency increases along the line.

If x is a complex signal of length NX, then S is a complex matrix of nfft row K columns, where k depends on window,

If window is a scalar, k = fix ((nx-noverlap)/(WINDOW-NOVERLAP))

If window is a vector, k = fix ((nx-noverlap)/(Length (window)-noverlap))

For real signal X, if Nfft is even, the number of lines of S is (nfft/2+1), if Nfft is odd,

The number of rows is (nfft+1)/2, and the number of columns is as above.

f---Use the f-frequency vector in the input variable, the function calculates the spectrogram at the frequency specified by F using the Goertzel method.

The specified frequency is rounded to the nearest DFT container (BIN) associated with the signal resolution. And in the other use Nfft

In syntax, the short-time Fourier transform method will be used. For the F vector in the return value, the length of the rounding frequency,

The number of rows equal to S.

T---The time point of the spectrogram calculation, whose length is equal to the k defined above, and the value is the midpoint of each segment.

P---Energy spectral density PSD (Power spectral Density), for real signals, p is the single-sided periodic estimation of each segment of PSD;

For complex signals, p is a bilateral PSD when the F frequency vector is specified.

The elements of the P-matrix are calculated as follows P (I,J) =k| S (I,j), where k is a real value scalar, defined as follows

For single-sided PSD, the formula is as follows, where W (n) Represents the window function, FS is the sampling frequency, at 0 frequency and Nyquist

At the frequency, the molecular factor 2 is changed to 1;

For bilateral PSD, the formula is as follows

If the sampling frequency is not specified, the FS on the denominator is replaced by 2*PI.

Spectrogram (...) When the function is called without an output parameter, the PSD estimate for each segment is automatically drawn, and the command is drawn as follows

Surf (T,F,10*LOG10 (ABS (P)));

Axis tight;

View (0,90);

Spectrogram (..., ' freqloc ') uses the Freqloc string to control the position of the frequency axis display. When Freqloc=xaxis

, the frequency axis is displayed on the x-axis, and when Freqloc=yaxis, the frequency axis is displayed on the y-axis, which is displayed by default on the x-axis

On If the freqloc is specified with an output variable, then Freqloc will be ignored.

For example, the PSD plot for two sweep signals is calculated and displayed, and the frequency of the sweep signal starts at 100Hz and 200Hz at 1s.

T = 0:0.001:2;

X = chirp (t,100,1,200, ' Q ');

Spectrogram (X,128,120,128,1E3);

Title (' Quadratic Chirp ');

For example, the PSD diagram of a linear sweep signal is calculated and displayed, the sweep signal is started by DC, and at 1s, the control frequency axis is displayed on the Y axis.

T = 0:0.001:2;

X = Chirp (t,0,1,150);

[S,f,t,p] = Spectrogram (X,256,250,256,1E3);

Surf (T,F,10*LOG10 (P), ' Edgecolor ', ' none '); Axis tight;

View (0,90);

Xlabel (' Time (Seconds) '); Ylabel (' Hz ');

Note for function use:

The larger the NFFT, the higher the resolution of the frequency domain (resolution =FS/NFFT), but the farther away from the instantaneous frequency;

Noverlap affect the resolution of the time axis, the closer to Nfft, the higher the resolution, the more redundant the corresponding, the greater the computational capacity, but the computer as long as can bear, the problem is not big.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.