参数
x
——输入的信号fs
——采样率,默认$2\pi$,正数标量t
——时间,向量,或者是datetime类型duration类型的数据,或者表示每个样本之间差值type
——用什么方式计算,可选是'power'
(default) |'spectrogram'
|'persistence'
以下是要写出名字的参数:
FrequencyLimits
——频带限制默认;[0 fs/2] 二元向量
FrequencyResolution
— Frequency resolution bandwidth频率分辨率实数标量,不能和时间分辨率一起指定。
Leakage
— Spectral leakage 泄漏量默认0.5
MinThreshold
— Lower bound for nonzero values 非零值的下限默认
-Inf
NumPowerBins
— Number of power bins for persistence spectrum默认256
OverlapPercent
— Overlap between adjoining segments 重叠率[0,100)
Reassign
— Reassignment option 重新分配??默认 false
TimeResolution
时间分辨率TwoSided
— Two-sided spectral estimate
Spectrogram Computation spectrogram的计算
To compute the time-dependent spectrum of a nonstationary signal, pspectrum
divides the signal into overlapping segments, windows each segment with a Kaiser window, computes the short-time Fourier transform, and then concatenates the transforms to form a matrix. For more information, see Spectrogram Computation with Signal Processing Toolbox.
A nonstationary signal is a signal whose frequency content changes with time. The spectrogram of a nonstationary signal is an estimate of the time evolution of its frequency content. To construct the spectrogram of a nonstationary signal, pspectrum
follows these steps:
Divide the signal into equal-length segments. The segments must be short enough that the frequency content of the signal does not change appreciably within a segment. The segments may or may not overlap.
Window each segment and compute its spectrum to get the short-time Fourier transform.
Use the segment spectra to construct the spectrogram:
- If called with output arguments, concatenate the spectra to form a matrix.
- If called with no output arguments, display the power of each spectrum in decibels segment by segment. Depict the magnitudes side-by-side as an image with magnitude-dependent colormap.
The function can compute the spectrogram only for single-channel signals.
Divide Signal into Segments
To construct a spectrogram, first divide the signal into possibly overlapping segments. With the pspectrum
function, you can control the length of the segments and the amount of overlap between adjoining segments using the 'TimeResolution'
and 'OverlapPercent'
name-value pair arguments. If you do not specify the length and overlap, the function chooses a length based on the entire length of the signal and an overlap percentage given by
(1−12×ENBW−1)×100,
where ENBW is the equivalent noise bandwidth of the spectral window. See enbw
and Spectrum Computation for more information.
Specified Time Resolution
If the signal does not have time information, specify the time resolution (segment length) in samples. The time resolution must be an integer greater than or equal to 1 and smaller than or equal to the signal length.
If the signal has time information, specify the time resolution in seconds. The function converts the result into a number of samples and rounds it to the nearest integer that is less than or equal to the number but not smaller than 1. The time resolution must be smaller than or equal to the signal duration.
Specify the overlap as a percentage of the segment length. The function converts the result into a number of samples and rounds it to the nearest integer that is less than or equal to the number.
Default Time Resolution
If you do not specify a time resolution, then pspectrum
uses the length of the entire signal to choose the length of the segments. The function sets the time resolution as ⌈N/d⌉ samples, where the ⌈⌉ symbols denote the ceiling function, N is the length of the signal, and d is a divisor that depends on N:
Signal Length (N) | Divisor (d) | Segment Length |
---|---|---|
2 samples – 63 samples |
2 |
1 sample – 32 samples |
64 samples – 255 samples |
8 |
8 samples – 32 samples |
256 samples – 2047 samples |
8 |
32 samples – 256 samples |
2048 samples – 4095 samples |
16 |
128 samples – 256 samples |
4096 samples – 8191 samples |
32 |
128 samples – 256 samples |
8192 samples – 16383 samples |
64 |
128 samples – 256 samples |
16384 samples – N samples |
128 |
128 samples – ⌈N / 128 ⌉ samples |
You can still specify the overlap between adjoining segments. Specifying the overlap changes the number of segments. Segments that extend beyond the signal endpoint are zero-padded.
Consider the seven-sample signal [s0 s1 s2 s3 s4 s5 s6]
. Because ⌈7/2⌉ = ⌈3.5⌉ = 4, the function divides the signal into two segments of length four when there is no overlap. The number of segments changes as the overlap increases.
Number of Overlapping Samples | Resulting Segments |
---|---|
0 |
s0 s1 s2 s3 s4 s5 s6 0 |
1 |
s0 s1 s2 s3 s3 s4 s5 s6 |
2 |
s0 s1 s2 s3 s2 s3 s4 s5 s4 s5 s6 0 |
3 |
s0 s1 s2 s3 s1 s2 s3 s4 s2 s3 s4 s5 s3 s4 s5 s6 |
pspectrum
zero-pads the signal if the last segment extends beyond the signal endpoint. The function returns t
, a vector of time instants corresponding to the centers of the segments.
Window the Segments and Compute Spectra
After pspectrum
divides the signal into overlapping segments, the function windows each segment with a Kaiser window. The shape factor β of the window, and therefore the leakage, can be adjusted using the 'Leakage'
name-value pair. The function then computes the spectrum of each segment and concatenates the spectra to form the spectrogram matrix. To compute the segment spectra, pspectrum
follows the procedure described in Spectrum Computation, except that the lower limit of the resolution bandwidth is
RBWperformance=4×fspan1024−1.
Display Spectrum Power
If called with no output arguments, the function displays the power of the short-time Fourier transform in decibels, using a color bar with the default MATLAB colormap. The color bar comprises the full power range of the spectrogram.