2021-02-28 Matlab draws short-time Fourier transform spectrogram and time-frequency-amplitude three-dimensional diagram

Matlab draws short-time Fourier transform spectrogram and time-frequency-amplitude three-dimensional diagram

 

function [t,frequency,f_spectrum]=fft_s(y,windowlength,Fs)
% 输入 : 
% y-输入信号
% windowlength-窗长度 0-1的系数,比如windowlength-0.5;采样频率1000,则窗长度为500
% Fs-采样频率
windowlength = windowlength*Fs;
y = reshape(y,windowlength,[]); % 数据分段

s = fft(y); % 快速傅里叶变换

d = abs(s(1:windowlength/2,:));% 求绝对值
f_spectrum = 2/windowlength*d; % 求幅值

t = (1:size(y,2))*windowlength/Fs; % 计算时间
frequency = (0:windowlength/2-1)/windowlength*Fs; % 频率范围


Guess you like

Origin blog.csdn.net/qingfengxd1/article/details/114237500