短时傅里叶变换(Short Time Fourier Transform)

1.什么是短时傅里叶变换?

在傅里叶变换的基础上,套用窗函数。即

2.示意图:

左图为傅里叶变换,可以观察整个时域上频率分布情况;右图为短时傅里叶变换,将时域进行了分割,可以观察某一时段上的频率分布情况,时间轴每格的长度即为窗函数的window length。

3.时间频率参数选取的关系

如左图,若横轴(时间)共1.2s,纵轴(频率)共50Hz,横轴划分为12格,每格0.1s,纵轴划分为两格,每格25Hz;右图横轴每格0.3s,纵轴每格约8Hz。无论怎样划分,两图中每个方块的面积是相同的,且横轴划分格数越少(如右图,即选取的数据点数多),频率划分越细(如右图,相比左图划分两格,右图纵轴共6格)。

因此可得,时间轴分辨率与频率分辨率成反比。时间轴分辨率低(选取点数少),则频率分辨率高(如右图,能细致观察频率但时间轴无法准确估计);反之频率分辨率低(左图,时间轴可准确估计但频率只能观察0-25和25-50Hz两部分)。

4.短时傅里叶变换有什么优势?

以一个频率从20Hz至100Hz随时间线性叠加的信号为例:

时域图形:

普通FFT:

此时并不能判断该信号的频域特性,似乎各个频率都有分布。

但使用短时傅里叶变换后,即可得出该信号特征:

短时傅里叶变换输出为三维图形,分别为时间、频率、强度三个轴(颜色即为对应时间、频率下的信号强度),时间频率轴上可明显观察到该信号的频率成分,随时间逐渐由20Hz线性增加到100Hz。

5.Matlab函数:

Matlab已集成了短时傅里叶变换的函数,具体使用方式为:

[s,f,t] = spectrogram(x,window,noverlap,f,fs)

% s为二维矩阵,大小为f*t;其中f为频率,t为时间
% 由于s为复数,实际使用时一般再增加一行求幅值代码
[spec,faxis,taxis]=spectrogram(data,hamming(nfft),noverlap,nfft,samplerate);
Mag=abs(spec);     % get spectrum magnitude

 

 

  • 17
    点赞
  • 105
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
function [S, f, t] = stft(x, fs, window, nfft, noverlap) % STFT - Short-time Fourier Transform % [S, f, t] = stft(x, fs, window, nfft, noverlap) % x: input signal % fs: sampling frequency % window: window function (default: hamming) % nfft: number of FFT points (default: length of window) % noverlap: number of samples overlapped between adjacent frames (default: 0) % S: STFT matrix (nfft/2+1 x nframes) % f: frequency vector % t: time vector % Example: % [x, fs] = audioread('speech.wav'); % [S, f, t] = stft(x, fs, hamming(512), 512, 256); % imagesc(t, f, 20*log10(abs(S))); % axis xy; colormap(jet); colorbar; xlabel('Time (s)'); ylabel('Frequency (Hz)'); % Written by Yuancheng Zhu (yzhu@nd.edu) % Last update: 2021/9/9 % Check inputs narginchk(2, 5); if nargin < 3 || isempty(window) window = hamming(256); end if nargin < 4 || isempty(nfft) nfft = length(window); end if nargin < 5 || isempty(noverlap) noverlap = 0; end if ~isvector(window) || ~isnumeric(window) error('Window function must be a numeric vector.'); end if ~isscalar(fs) || ~isnumeric(fs) || fs <= 0 error('Sampling frequency must be a positive scalar.'); end if ~isscalar(nfft) || ~isnumeric(nfft) || nfft <= 0 error('Number of FFT points must be a positive scalar.'); end if ~isscalar(noverlap) || ~isnumeric(noverlap) || noverlap < 0 error('Number of overlapped samples must be a non-negative scalar.'); end if noverlap >= length(window) error('Number of overlapped samples must be less than the window length.'); end % Calculate STFT parameters nframes = fix((length(x)-noverlap)/(length(window)-noverlap)); if nframes < 1 error('Signal is too short for STFT with the given parameters.'); end x = x(:); window = window(:); S = zeros(nfft/2+1, nframes); t = (nfft/2:nfft/2+nframes-1) / fs; % Compute STFT for i = 1:nframes idx = (1:length(window)) + (i-1)*(length(window)-noverlap); if idx(end) > length(x) idx = idx(idx <= length(x)); xw = [x(idx); zeros(length(window)-length(idx), 1)]; else xw = x(idx) .* window; end X = fft(xw, nfft); S(:, i) = X(1:nfft/2+1); end f = (0:nfft/2)' / nfft * fs; end

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值