Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] FFT alternates '0' for a quantized SIN wave

Status
Not open for further replies.

pavel47

Member level 4
Joined
Nov 8, 2005
Messages
68
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Switzerland
Activity points
1,790
Hello,

Doing FFT exercises in Matlab I've discovered that for some frequencies (defined by k) the FFT of quantized SIN wave alternates '0'.
For k I used primary numbers.
With k = 11, 13, 17, 19, 23, 29, 31, 37 it's Ok
With K = 3, 5, 7, 41, 53, 67, 101, 127 FFT alternates '0'.
Any ideas ?

Thanks in advance.

Pavel.


Code:
close all;
% clear all;

L = 2^14;
res = 10;
A = 1;

Fs = 1e+5;
k = 41;
f1 = k/L*Fs;

t = (0:L-1)/Fs;
y = A*sin(2*pi*f1*t);

% Display Original Signal
figure(1)
plot(t, y);
grid on;

% Quantization
dA = (2*A)/2^res;
partition = (-A+dA:dA:A-dA);
codebook = (0:2^res-1);
[index,yq] = quantiz(y,partition,codebook);
yq = (yq - 2^(res-1))/2^res*2*A;

% Display Quantized Signal
figure(2);
plot(t,yq);
grid on;

% Display Quantization Error
figure(3);
plot(t, y-yq);
grid on;

P2 = abs(fft(yq, L))/L;
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;

% Display FFT
figure(4);
plot(f, mag2db(P1));
grid on;

FFT_alternates_zeros.JPG
 

Here is resume of FFT calculations for different values of k (picked from primary numbers): y - FFT Ok, n - FFT alternates '0'.
FFT_of_SIN_with_differents_f1.JPG
 

Resolved.
The problem was in erroneous quantization.
Here is the correct quantization code:

% Quantization
dy = (2*A)/(2^res-1);
partition = (-A+A/2^res:dy:A-A/2^res);
codebook = (0:2^res-1);
[index,yq] = quantiz(y,partition,codebook);
yq = 2*A*yq/(2^res-1)-A;


where:
y - SIN waveform values
A - amplitude of SIN waveform
res - resolution of quantizer
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top