Recovering signal from magnitude and phase of FFT 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?
I tried running the same code, and it works fine, except for 2 minor points:


It's preferable to use exp(1i*phase) instead of exp(sqrt(-1)*phase)
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