Relation between sampling frequency and quantization

Status
Not open for further replies.

papriko

Newbie level 4
Joined
Feb 5, 2010
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Lyon
Activity points
1,324
Hello , i'm newbie here .
Just a simple question , is there a relation between sampling frequency and quantization ?
I implement a quantization script under MATLAB 7.0.14 for quantizating signals.
Theorically the quantized signal must be like stairs , not a line !
These are my results :
For fs(frequency sampling)= 10^2 , I got this :



and for fs=10^3 , I got :


So is there somthing wrong ?
 

fs is proportional to the no. of quantization levels in case of smooth signals like your sine wave.
 

    papriko

    Points: 2
    Helpful Answer Positive Rating
both of cases it's propotional !
 

papriko said:
both of cases it's propotional !
For example, a BPSK signal with higher sampling frequency won't require more quantization levels I think, right?
 

Here is my code :
Code:
A=2;
f=2;
fs=10^2;
t=10^-2:1/fs:1;
x=A*cos(2*3.15*f*t);
Nor=max(abs(x)); 
xnor=x/(Nor);  
i=0;

for i=0:2^N
    s(i+1)=-1+i*2^(1-N);   
end

for i=1:2^N
   m=find( ( xnor>=s(i) ) & ( xnor<s(i+1) ) );
   for j=1:length(m)
        xnq(m(j))=(s(i)+s(i+1))/2;
   end
end
xq=Nor*xnq ;
figure,plot(t,xq)
N = 4 ;
if fs=10^2 i got the first figure , if fs=10^3 i got the second one
and quantized signal must look like a straicase !

Added after 3 minutes:

hesham_eraqi said:
For example, a BPSK signal with higher sampling frequency won't require more quantization levels I think, right?
really don't know, digital signal processing is all new for me
 

There are a few problems with your code...
The best way to define a sinewave is:
Code:
A=1;
n=7;
N=2^n; % simulation length
fs=1e2; % sampling frequency
t=(0:N-1)/fs; % time (sampling points)
f=3*fs/N; % sinewave frequency 
x=A*sin(2*pi*f*t); % cw sinewave
r=10; % number of bits of resolution
R=2^R; % number of quantization levels
q=floor(R*x/2)+R/2; % the quantizer!
stairs(t,q);
In general, it is good to choose f/fs=M/N, where M is an odd number that creates a frequency close to your desired frequency and N is the simulation time.

I hope this help!
 

You didn't help me, but i learned from you a new commands on Matlab ; and you made a simple and faster quantizer , thank you so much.
Now , I know what is the problem , it's about "plot" in Matlab, because there's not enough sample for the same level of quantization , the graph is seem to be a line .

hesham_eraqi , JoannesPaulus thank you
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…