Facebook
From tn, 2 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 196
  1. A1=8;
  2. fs=1000;% sampling frequency
  3. fc=150;% frequency of the signal
  4. t=0:1/fs:1;%discrete time
  5. x=A1*cos(2*pi*fc*t);% discrete signal
  6. %--------Quantization------------%
  7. n=4;
  8. L=(2^n);
  9. delta=(max(x)-min(x))/L;
  10. xq=min(x)+(round((x-min(x))/delta)).*delta;
  11. %--------END------------%
  12. subplot(2,1,1)
  13. stem(t,x,'R');
  14. subplot(2,1,2);% breaking the window figure to plot both graphs
  15. stem(t,x,'b');% plot of discrete time signaltitle('Discrete time representation')% title of the figure
  16. xlabel('time(s)')% label on the x-axis of the plot
  17. ylabel('X[n]')% label on the y-axis of the plot
  18. subplot(2,1,2);
  19. stairs(t,xq,'b');% the quantized output
  20. title('Quantized Signal')% title of the figurea
  21. xlabel('time')% label on the x-axis of the plot
  22. ylabel('amplitude')% label on the y-axis of the plot