小波变换matlab时频谱,小波变换 时频分析

这是官网上别人给出的短时傅里叶变换的源码,有兴趣的话可以看一下!

http://www.mathworks.com/matlabc ... tlab-implementation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%              Short-Time Fourier Transform            %

%               with MATLAB Implementation             %

%                                                      %

% Author: M.Sc. Eng. Hristo Zhivomirov       12/21/13  %

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function [stft, f, t] = stft(x, wlen, h, nfft, fs)

% function: [stft, f, t] = stft(x, wlen, h, nfft, fs)

% x - signal in the time domain

% wlen - length of the hamming window

% h - hop size

% nfft - number of FFT points

% fs - sampling frequency, Hz

% f - frequency vector, Hz

% t - time vector, s

% stft - STFT matrix (only unique points, time across columns, freq across rows)

% represent x as column-vector if it is not

if size(x, 2) > 1

x = x';

end

% length of the signal

xlen = length(x);

% form a periodic hamming window

win = hamming(wlen, 'periodic');

% form the stft matrix

rown = ceil((1+nfft)/2);            % calculate the total number of rows

coln = 1+fix((xlen-wlen)/h);        % calculate the total number of columns

stft = zeros(rown, coln);           % form the stft matrix

% initialize the indexes

indx = 0;

col = 1;

% perform STFT

while indx + wlen <= xlen

% windowing

xw = x(indx+1:indx+wlen).*win;

% FFT

X = fft(xw, nfft);

% update the stft matrix

stft(:, col) = X(1:rown);

% update the indexes

indx = indx + h;

col = col + 1;

end

% calculate the time and frequency vectors

t = (wlen/2:h:wlen/2+(coln-1)*h)/fs;

f = (0:rown-1)*fs/nfft;

end

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值