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.

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 :D .
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 :

2rrp62p.png


and for fs=10^3 , I got :
5a0rk4.png


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!
 

JoannesPaulus said:
There are a few problems with your code...
The best way to define a sinewave is:
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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top