Borrar filtros
Borrar filtros

speeding up ifft with conjugate symmetry

16 visualizaciones (últimos 30 días)
markushatg
markushatg el 13 de Dic. de 2012
Comentada: ro bader el 15 de Mayo de 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)

Respuestas (1)

Wayne King
Wayne King el 13 de Dic. de 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 comentario
ro bader
ro bader el 15 de Mayo de 2020
Is there a way other thann the option 'symmetric'?

Iniciar sesión para comentar.

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by