How to get a real signal from complex ifft values? I am trying to understand the difference between DCT and FFT in the context of compression. There is a nice practical example given here. (near the end of the page) 

When I try it in matlab I am stuck at plotting the ifft values (which are complex). The plot command cannot plot the complex signal. One natural question comes to my mind, when is the ifft value complex, and when is it real? If it is complex, is it fine to discard the imaginary parts and keep only the real part?

What is the right way to reconstruct the real signal x from ifft complex values?
You can plot the real and imaginary components from the FFT result separately (or the magnitude and the phase results separately, as two plots).  Then you can recombine the data from the two plots into a complex spectrum required to do a reconstruction IFFT.  Both components are required, otherwise you've thrown away half the information about your signal, and can't reconstruct it (unless the original signal was purely symmetric or purely anti-symmetric to begin with).

The plot data isn't really doubled when you do two plots because the result of an FFT of strictly real inputs in conjugate symmetric.  Thus you can create the input for your reconstruction IFFT from only the first half of the data for the real plot and for the imaginary plot (by conjugate mirroring it to the other half).