필터 지우기
필터 지우기

speeding up ifft with conjugate symmetry

조회 수: 16 (최근 30일)
markushatg
markushatg 2012년 12월 13일
댓글: ro bader 2020년 5월 15일
In my MATLAB program I convert a time signal to the frequency domain and then back to time domain via the overlap add method.
According to the documentation, ifft(X) is faster if X is conjugate symmetric.
going from frequency to time I've tried
Yn = Xn;
yn = ifft(Yn, N);
versus the following, where I've tried to implement it as I understand the documentation
Yn(1:N) = Xn;
Yn = [Yn(1:N) fliplr(conj(Yn(1:N)))];
yn = ifft(Yn, N);
N = length(Xn), which is the same in both cases.
In both cases I preallocate the needed memory, but the first one is always faster than the second.
What am I doing wrong?
The full code is downloadable from my dropbox: https://dl.dropbox.com/u/51552385/overlap_add.m
Thanks for your help
Full code:
L = 64; %Blocklength/Number of bands
M = L/2; %filterlength/Decimation factor
N = L + M - 1; %fft- and ifft length
fs = 20e3;
x = randn(1, 2*fs); %generate full input signal
y = zeros(1, length(x)); %allocate memory for y
y = [y zeros(1, M-1)]; %add extra space for last overlap, eventually to be cut away
complex = false; %choose ifft method
if(complex)
Yn = [y y];
end
tic
for n = 1:length(x)/L
blockn = [x((n-1)*L+1:n*L) zeros(1,M-1)]; % blockn is equal to nth block
Xn = fft(blockn, N);
if(complex)
Yn(1:N) = Xn;
Yn = [Yn(1:N) fliplr(conj(Yn(1:N)))];
yn = ifft(Yn, N);
else
Yn = Xn;
yn = ifft(Yn, N);
end
%overlap and add current block to output signal y
y((n-1)*L+1:N+(n-1)*L) = y((n-1)*L+1:N+(n-1)*L) + yn;
end
toc
y = y(1:length(x)); %cut away last overlap
error = norm(y-x)

답변 (1개)

Wayne King
Wayne King 2012년 12월 13일
Have you tried just using the 'symmetric' flag to treat the input as conjugate symmetric?
t = 0:0.001:1-0.001;
x = cos(2*pi*100*t)+randn(size(t));
xdft = fft(x);
xhat = ifft(xdft,'symmetric');
  댓글 수: 1
ro bader
ro bader 2020년 5월 15일
Is there a way other thann the option 'symmetric'?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by