after applying a filter -i design- to a real signal, it returns complex signal after ifft

1 回表示 (過去 30 日間)
[x,fs]=audioread('some.wav');
n=length(x);
t = ((0:n-1)*(fs/n));
y=fft(x);
f = ((0:n-1)*(fs/n));
y0 = fftshift(y);
f0 = ((-n/2:n/2-1)*(fs/n));
noise = find(abs(y0) == max(abs(y0)));
noiseW= [2*pi*f0(noise(1)) 2*pi*f0(noise(2))];
z1=exp(1i*noiseW(1));
z2=exp(1i*noiseW(2));
z=exp(1i*2*pi*f0);
H=(1-z1*(z.^-1)).*(1-z2*(z.^-1));
out0=y0.*(H.');
out=ifftshift(out0);
signal=ifft(out);
audiowrite('output.wav',final,fs);
  2 件のコメント
Daniel Pollard
Daniel Pollard 2021 年 5 月 14 日
I'm not sure I understand the problem. The FFT (and the IFFT) produce complex outputs by their definition. Could you give some more details? What were you expecting to happen?
Hamza AKYILDIZ
Hamza AKYILDIZ 2021 年 5 月 14 日
some.wav file is a real signal. after i apply the filter H to it, i expect it to be still real after ifft.

サインインしてコメントする。

採用された回答

Paul Hoffrichter
Paul Hoffrichter 2021 年 5 月 14 日
Your imaginary part only is non-zero due to the usual floating point roundoffs and truncations. Fix this using round:
signal=ifft(out);
signalRound = round(signal, 10);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultirate Signal Processing についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by