bcosta
Newbie level 4
dft in matlab
Hi all,
I have recently been reviewing DSP (I did DSP at university a number of years ago and am trying to refresh). I have recently just read a textbook I found (not from my University studies) that has been very helpful. In the book they distinguish between the “Real DFT” and the “Complex DFT” and went through most of the book using just the real DFT. I do not remember coming across this distinction while at University.
I want to play around with a few things in matlab now, but as I understand it the fft() and ifft() functions in Matlab implement the “Complex DFT” using the fast fourier transform algorithm. Is anyone aware of functions for computing the “Real DFT” in Matlab?
Also, could someone let me know if my understanding of the relationship between the two as described below is correct?
Real DFT:
Converts N samples to two sets of N/2 + 1 samples (ImX[] and ReX[] according to the text book). These are not really complex numbers but are the amplitudes of the basis functions (cosine and sine waves) that can be combined to make up the time domain signal. Since they are the amplitudes of cosine and sine basis functions they can be treated as the real and imaginary parts of complex numbers through substitution. One purpose of doing this is to convert them into polar form by creating N/2 + 1 size magnitude and phase vectors RMagX[] RPhaseX[] from the complex numbers, giving the magnitude and phase of the frequency response.
If converting to polar form, the values for RMagX and RPhaseX give the magnitude and phase from k = 0 (DC) to k = fs/2.
Complex DFT:
Converts N complex number samples in the “time domain” into N complex number samples in the frequency domain. This includes the negative frequencies from –fs/2 to 0 which are generally a duplicate of the positive frequencies (as I understand it when the time domain samples are purely real then the negative frequencies mirror the positive ones).
The values can be represented in polar form CMagX, CPhaseX both N samples in size.
The relationship between the real DFT polar form and the complex DFT polar form, is that the first N/2 samples of CMagX and RMagX would be the same (possibly with scaling differences), and the first N/2 samples of CPhaseX and RPhaseX would also be the same. This comes from the fact that the real DFT “assumes” a mirrored set of negative frequencies due to the fact that the real DFT only ever transforms real time domain signals and never complex ones (thus producing mirrored negative frequencies).
If this is correct and I have the samples for a “Real DFT” in the frequency domain, I could create the “Complex DFT" samples in the frequency domain by simply mirroring the values for RMagX and RPhaseX in the range 0 to N/2 into the range N/2 + 1 N for CMagX and CPhaseX. Is this correct?
Finally as a last question, do people generally use the real DFT or the complex DFT for most of their DSP work? What sorts of applications would you choose to use each of these for?
Thanks,
Brendon.
Hi all,
I have recently been reviewing DSP (I did DSP at university a number of years ago and am trying to refresh). I have recently just read a textbook I found (not from my University studies) that has been very helpful. In the book they distinguish between the “Real DFT” and the “Complex DFT” and went through most of the book using just the real DFT. I do not remember coming across this distinction while at University.
I want to play around with a few things in matlab now, but as I understand it the fft() and ifft() functions in Matlab implement the “Complex DFT” using the fast fourier transform algorithm. Is anyone aware of functions for computing the “Real DFT” in Matlab?
Also, could someone let me know if my understanding of the relationship between the two as described below is correct?
Real DFT:
Converts N samples to two sets of N/2 + 1 samples (ImX[] and ReX[] according to the text book). These are not really complex numbers but are the amplitudes of the basis functions (cosine and sine waves) that can be combined to make up the time domain signal. Since they are the amplitudes of cosine and sine basis functions they can be treated as the real and imaginary parts of complex numbers through substitution. One purpose of doing this is to convert them into polar form by creating N/2 + 1 size magnitude and phase vectors RMagX[] RPhaseX[] from the complex numbers, giving the magnitude and phase of the frequency response.
If converting to polar form, the values for RMagX and RPhaseX give the magnitude and phase from k = 0 (DC) to k = fs/2.
Complex DFT:
Converts N complex number samples in the “time domain” into N complex number samples in the frequency domain. This includes the negative frequencies from –fs/2 to 0 which are generally a duplicate of the positive frequencies (as I understand it when the time domain samples are purely real then the negative frequencies mirror the positive ones).
The values can be represented in polar form CMagX, CPhaseX both N samples in size.
The relationship between the real DFT polar form and the complex DFT polar form, is that the first N/2 samples of CMagX and RMagX would be the same (possibly with scaling differences), and the first N/2 samples of CPhaseX and RPhaseX would also be the same. This comes from the fact that the real DFT “assumes” a mirrored set of negative frequencies due to the fact that the real DFT only ever transforms real time domain signals and never complex ones (thus producing mirrored negative frequencies).
If this is correct and I have the samples for a “Real DFT” in the frequency domain, I could create the “Complex DFT" samples in the frequency domain by simply mirroring the values for RMagX and RPhaseX in the range 0 to N/2 into the range N/2 + 1 N for CMagX and CPhaseX. Is this correct?
Finally as a last question, do people generally use the real DFT or the complex DFT for most of their DSP work? What sorts of applications would you choose to use each of these for?
Thanks,
Brendon.