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