Why does the 21 Point DFT in MATLAB produce so many zero values?

  • Thread starter Thread starter impervious
  • Start date Start date
  • Tags Tags
    Dft Matlab Point
AI Thread Summary
The discussion centers on the phenomenon of obtaining many zero values in the 21-point Discrete Fourier Transform (DFT) in MATLAB. The user presents MATLAB code that generates a boxcar function, leading to a DFT output that does not resemble typical sinc functions. It is noted that the boxcar function's lack of centering introduces a complex phase, affecting the DFT results. The phase plot reveals a pattern where every third element has a phase of approximately ±π, indicating a relationship to the boxcar's positioning. Understanding these aspects clarifies why the DFT exhibits zero values and deviates from expected sinc function characteristics.
impervious
Messages
2
Reaction score
0
Hello, I was trawling through some MATLAB work, and came across a question that bugged me, and I hope that someone might be able to give a suitable explanation.

The question was explain why the 21 point DFT has so many values equal to zero. Both DFT's are sinc functions where:

sinc(L)= sin(L * theta)/sin(L)

Heres my MATLAB code :

>> nn=0:20;
>> x=zeros(21,1);
>> x(1:7)=boxcar(7);
>> X=fft(x);
>> subplot(2,2,1),stem(nn,x);
>> subplot(2,2,2),stem(nn,abs(X));
>> subplot(2,2,3),stem(nn,angle(X));

The output of this is attached.

I understand that the basic sinc function is widely used in signals due to its zero crossings, however neither the input of the output look much like sinc functions I have seen before.

Any suggestions much appreciated.
 

Attachments

  • fft.jpg
    fft.jpg
    13.6 KB · Views: 591
Physics news on Phys.org
Your boxcar isn't centered, so it's introducing a complex phase. Try setting x to {1,1,1,1,0,...,0,1,1,1}. You'll then find the imaginary parts of X are essentially 0. Plot the real part of X, and it'll look like a sinc function.
 
Unfortunately I think I am using the boxcar they want me to use, and are talking in relation to the six zero points in my DFT.
Since they occur at sampling integers of 3, I can't help but feel this is somehow an important point that I don't understand.
 
Your first plot of X isn't of the plain sinc function; it's a plot of its absolute value. Can you see why your plot looks the way it does now?

On the phase plot, you might notice that the phase of every third element is essentially ±π. If you ignore those, you can see the remaining phases follow a nice pattern. That pattern arises because your boxcar isn't centered in the time domain.
 
Back
Top