0
$\begingroup$

I'm trying to code the basics of an analysis-synthesis system on MATLAB, but I'm getting incorrect results. From the Wikipedia page:

$$ X_k=\lvert X_k\rvert e^{i\angle X_k} $$

Here's a simple MATLAB code:

y = speech(10:10+127);

yfft = fft(y,128);

spec = abs(yfft);
phase = unwrap(angle(yfft));

Y = spec .* exp(sqrt(-1)*phase);

yinv = ifft(Y,128);

yet y and yinv do not match. What's the issue here?

$\endgroup$
  • $\begingroup$ what's your sample rate? 128 samples worth of DFT surely doesn't sound like a "recognizable" sound. $\endgroup$ – Marcus Müller Aug 19 '16 at 9:11
2
$\begingroup$

I tried running the same code, and it works fine, except for 2 minor points:

  1. It's preferable to use exp(1i*phase) instead of exp(sqrt(-1)*phase)
  2. The final result will deviate from the original signal due to rounding noise (typically around 1e-16). Also, some of this noise will appear in the imaginary part of the result (so, even if y was real, yinv will be complex, due to the small imaginary component). This will be particularly apparent if you try: plot(yinv), because Matlab will see that yinv is complex, and plot it on the real/imag axis
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.