Filter löschen
Filter löschen

speeding up ifft with conjugate symmetry

16 Ansichten (letzte 30 Tage)
markushatg
markushatg am 13 Dez. 2012
Kommentiert: ro bader am 15 Mai 2020
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)

Antworten (1)

Wayne King
Wayne King am 13 Dez. 2012
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 Kommentar
ro bader
ro bader am 15 Mai 2020
Is there a way other thann the option 'symmetric'?

Melden Sie sich an, um zu kommentieren.

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by