• 【限免】短时傅里叶变换时频分析【附MATLAB代码】


    来源:微信公众号:EW Frontier

    简介

    一种能够同时对信号时域和频域分析的方法——短时傅里叶变换(STFT),可以在时频二维角度准确地描述信号 的时间、频域的局部特性,与其他算法不同,通过该算法可以得到信号的瞬时频率随时间变化的变化规律,其在雷达信号的脉内 特征分析中的效果明显。本文根据仿真结果,对不同类型信号经短时傅里叶变换后的结果进行统计,形成了基于短时傅里叶变换 的雷达信号脉内特征自动识别流程,对电子侦察情报的获取及应用有重要的意义。

    电子侦察面对的电磁环境越来越复杂,这意味着雷达 信号越来越复杂,也就是说雷达信号环境中常规脉冲雷达信 号使用的比例逐渐减小。因此,对线性调频、相位编码、非 线性调频、频率捷变等雷达信号的识别已成为不可忽视重要 环节,同时,高速地对这些信号进行自动识别也是发展的需 求。本文利用短时傅里叶变换对各种复杂信号进行脉内特征 分析,以探索脉内特征自动识别流程。

    STFT主要原理

    短时傅里叶变换公式为:

    式(1)中,m(τ-t)为窗函数在时域窗函数取截信号, 窗函数滤波出来的局部时域数据作FFT,就是在τ时刻得 到该时域窗函数对应信号的傅里叶变换,设置不同的τ值, 窗函数的中心位置会不断移动,这样就得到了不同τ下该信 号的傅里叶变换,这些不同时刻傅里叶变换的集合就是Sx (ω,t)。

    从式(1)可以发现,从形式上来看,傅里叶变换和短时傅里叶变换的区别仅在于时间域上少了一个窗函 数。短时傅里叶变换通过采用滑窗处理来弥补传统傅里叶 变换的不足之处。它能够对某一小段时间滑窗内的信号做 傅里叶变换,反映该信号的频域随时间变换的大致规律。 同时,短时傅里叶变换还保留了传统傅里叶变换较好的抗 干扰能力。仿真研究表明,若时域的滑窗时间越短,则变 换后的频率分辨率会越低;若滑窗时间延长,则时域的分 辨率就会降低,这是短时傅里叶变换在时域分辨率、频域 分辨率方面存在的矛盾。

    MATLAB代码

    1. function [t, f, S] = stft1(x,N,M,Nfft,Fs,win_type)
    2. %STFT1 Short-Time Fourier Transform (STFT) - Method I.
    3. %
    4. % [t, f, S] = stft1(x,N,M,Nfft,Fs,win_type) calculates the Short-Time Fourier Transform
    5. % (STFT) or in other words the spectrogram of the input signal x.
    6. %
    7. % Inputs:
    8. % x is a row vector that contains the signal to be examined.
    9. % N is the selected length of the window in samples.
    10. % M is the selected amount of overlap between successive windows in samples.
    11. % Nfft is the selected number of DFT calculation points (Nfft>=N).
    12. % Fs is the signal sampling frequency in Hz.
    13. % win_type is a string containing one of the windows shown
    14. % below. The default value of this variable corresponds to the rectangular window.
    15. %
    16. % Outputs: S is a matrix that contains the complex spectrogram of x.
    17. % i.e. S(:,k) = fft(k-th frame) computed on Nfft points.
    18. % f is a vector of frequency points in Hz where the spectrogram is calculated.
    19. % t is a vector of time points in sec. Each point corresponds to a
    20. % signal frame.
    21. %
    22. % Copyright 2020-2030, Ilias S. Konsoulas.
    23. %% Window selection and contruction.
    24. switch win_type
    25. case 'cheby'
    26. win = chebwin(N).';
    27. case 'blackman'
    28. win = blackman(N).';
    29. case 'hamm'
    30. win = hamming(N).';
    31. case 'hann'
    32. win = hanning(N).';
    33. case 'kaiser'
    34. beta = 5;
    35. win = kaiser(N,beta).';
    36. case 'gauss'
    37. win = gausswin(N).';
    38. otherwise % otherwise use the rectangular window
    39. win = ones(1,N);
    40. end
    41. %% Input Signal Segmentation Params.
    42. x = x(:).';
    43. L = length(x);
    44. % Number of segments (frames) the signal is divided to.
    45. K = floor((L-M)/(N-M));
    46. %% DFT Matrix Construction
    47. n = 0:Nfft-1;
    48. w = exp(-1i*2*pi*n/Nfft);
    49. W = zeros(Nfft,Nfft);
    50. for k=0:Nfft-1
    51. W(:,k+1) = w.^k;
    52. end
    53. %% Number of Unique FFT Points.
    54. NUPs = Nfft;
    55. if isreal(x)
    56. if mod(Nfft,2) % if N is odd.
    57. NUPs = (Nfft+1)/2;
    58. else % if N is even.
    59. NUPs = Nfft/2+1;
    60. end
    61. end
    62. %% Input Signal Segmentation (Framing)
    63. X = zeros(N,K);
    64. for k=1:K
    65. X(:,k) = x((k-1)*(N-M)+1:k*N - (k-1)*M).*win;
    66. end
    67. X = vertcat(X,zeros(Nfft-N,K)); % Zero-Padding each frame.
    68. %% DFT Calculation of all frames as a single matrix product.
    69. S = W*X;
    70. S = S(1:NUPs,:);
    71. %% Frame Time Points
    72. t = (N-1)/Fs + (0:K-1)*(N-M)/Fs; % Frame Time Points.
    73. %% Frequency Points in Hz.
    74. f = (0:NUPs-1)*Fs/Nfft;
    75. %% NOTES:
    76. % When K is an integer then the following equation holds:
    77. % (N-1)*Ts + (K-1)*(N-M)*Ts = (L-1)*Ts = total signal duration in sec.
    78. % or (N-1) + (K-1)*(N-M) = (L-1).
     
    
    1. % Short-Time Fourier Transform - Method I (Spectrogram) Demo.
    2. % This demo shows how the custom function stft1.m and is used to
    3. % to produce the spectrogram of an input signal.
    4. % Copyright 2020 - 2030, Ilias S. Konsoulas.
    5. %% Workspace Initialization.
    6. clc; clear; close all;
    7. %% Select and load the signal to be analyzed.
    8. % load('chirp','Fs','y'); x = y;
    9. % load('gong', 'Fs','y'); x = y;
    10. % load timit2.asc; Fs = 8000; x = timit2;
    11. % load('train','Fs','y'); x = y;
    12. load('splat','Fs','y'); x = y;
    13. % load('laughter','Fs','y'); x = y;
    14. % [x Fs] = audioread('andean-flute.wav');
    15. %% Play Back the selected audio signal:
    16. soundsc(x,Fs,24);
    17. %% Signal Normalization.
    18. x = x.'/max(abs(x));
    19. %% STFT Parameters.
    20. L = length(x);
    21. N = 512; % Selected window size.
    22. M = 450; % Selected overlap between successive segments in samples.
    23. Nfft = 512; % Selected number of FFT points.
    24. [t,f,S] = stft1(x,N,M,Nfft,Fs,'hamm');
    25. %% Plot the Spectrogram.
    26. h = figure('Name','STFT - Method I Demo');
    27. colormap('jet');
    28. [T,F] = meshgrid(t,f/1000); % f in KHz.
    29. surface(T,F,10*log10(abs(S.^2) + eps),'EdgeColor','none');
    30. axis tight;
    31. grid on;
    32. title(['Signal Length: ',num2str(L),', Window Length: ', num2str(N),', Overlap: ', num2str(M), ' samples.']);
    33. xlabel('Time (sec)');
    34. ylabel('Frequency (KHz)');
    35. colorbar('Limits',[-80, 40]);
    36. cbar_handle = findobj(h,'tag','Colorbar');
    37. set(get(cbar_handle,'YLabel'),'String','(dB)','Rotation',0);
    38. zlim([-80 40]);

    MATLAB仿真结果

  • 相关阅读:
    【乘风伯乐奖】寻找百位乘风者伯乐,邀请新博主入驻即可获奖
    如何设计一个网络爬虫?
    edm邮件开发信模板
    不同content-type对应的前端请求参数处理格式
    如何配置一台适合oc渲染器的电脑?
    硫酸钴溶液除杂回收技术分享
    自动化任务调度,轻松管理海量数据采集项目
    渐进式 shiro - shiro + jwt+salt (二)
    Ubuntu安装PCAN-View
    Jsp+MySQL学生学籍信息管理系统 Java毕业设计
  • 原文地址:https://blog.csdn.net/m0_54016576/article/details/139211387