matlab中傅里叶反转亮度,短时傅里叶逆变换matlab命令

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

%          Inverse Short-Time Fourier Transform        %

%               with MATLAB Implementation             %

%                                                      %

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

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

function [x, t] = istft(stft, wlen, hop, nfft, fs)

% function: [x, t] = istft(stft, wlen, hop, nfft, fs)

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

% wlen - length of the sinthesis Hamming window

% hop - hop size

% nfft - number of FFT points

% fs - sampling frequency, Hz

% x - signal in the time domain

% t - time vector, s

% signal length estimation and preallocation

coln = size(stft, 2);

xlen = wlen + (coln-1)*hop;

x = zeros(1, xlen);

% form a periodic hamming window

win = hamming(wlen, 'periodic');

% initialize the signal time segment index

indx = 0;

% perform ISTFT (via IFFT and Weighted-OLA)

if rem(nfft, 2)                     % odd nfft excludes Nyquist point

for col = 1:coln

% extract FFT points

X = stft(:, col);

X = [X; conj(X(end:-1:2))];

% IFFT

xprim = real(ifft(X));

xprim = xprim(1:wlen);     %?????????????????????????????

% weighted-OLA

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

% update the index

indx = indx + hop;

end

else                                % even nfft includes Nyquist point

for col = 1:coln

% extract FFT points

X = stft(:, col);

X = [X; conj(X(end-1:-1:2))];

% IFFT

xprim = real(ifft(X));

xprim = xprim(1:wlen);

% weighted-OLA

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

% update the index

indx = indx + hop;

end

end

% scale the signal

W0 = sum(win.^2);

x = x.*hop/W0;

% generate time vector

t = (0:xlen-1)/fs;

end

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值