Yesterday I posted following topic: "FFT alternates '0' for a quantized SIN wave". During post editing I was perturbed by some affair, I didn't formulate correctly the problem. So, my post was blocked (i.e. "hold on"). My subsequent update didn't modify the post status: it remains "hold on".
Since, I advanced in the problem resolution. The problem originates from erroneous quantization of SIN waveform. For quantization I use Matlab "quantiz" function, that take 2 parameters: "partition" and "codebook". After changing the fragment of code that is related to quantization (please, see below) the problem disappears, i.e. FFT displays correctly for all frequencies of SIN waveform.
dy = (2*A)/2^res; partition = (-A+3/2^(res+1):dy:A-3/2^(res+1)); codebook = (0:2^res-1); [index,yq] = quantiz(y,partition,codebook); yq = 2*yq/(2^res-1)-1;
A - amplitude of SIN wave (=1)
res - resolution of quantizer (10bit)
But nevertheless some incertitude remains: when I to solve the same task in Simulink (using "Ideal ADC Quantizer" block, the results of Simulink simulation are slightly different from Matlab simulation.
Any suggestions ?
Here is also comparison of 2 FFTs:
- SIN waveform, quantized in Simulink (TOP)
- SIN waveform, quantized in Matlab and imported in Simulink (Bottom)