0% found this document useful (0 votes)
73 views4 pages

Codes For The Graph of The Given Question

The document contains code to generate and plot a simulated analog signal with two frequencies. It then samples the signal and plots the quantized digital version. A table shows the quantization of 10 samples over 1ms using a 4-bit quantizer. It lists the sample time, code number, binary code, and gray code for each sample. The document also provides calculations to determine the sampling rate is 10 kHz, quantization step size is 0.5, and the total number of bits needed to represent the 10 samples is 40 bits.

Uploaded by

Calvinho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views4 pages

Codes For The Graph of The Given Question

The document contains code to generate and plot a simulated analog signal with two frequencies. It then samples the signal and plots the quantized digital version. A table shows the quantization of 10 samples over 1ms using a 4-bit quantizer. It lists the sample time, code number, binary code, and gray code for each sample. The document also provides calculations to determine the sampling rate is 10 kHz, quantization step size is 0.5, and the total number of bits needed to represent the 10 samples is 40 bits.

Uploaded by

Calvinho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Qn 1.

3
CODES FOR THE GRAPH OF THE GIVEN QUESTION
freq = 2000; % frequency
mag1 = 3; % magnitude-1
mag2=0.5; % magnitude-2
num_points = 200; % How many points to use
% 200 makes it look smooth
step = 2/(freq*num_points); % get a nice step size
t = 0:step:2*(1/freq); % "time"
% x and y are simulated analog functions
x = mag1*sin(2*pi*freq*t ) + mag2*cos(1*pi*freq*t );
% Plot the "analog" signals
plot(t, x, 'r.-');
grid on
my_title = sprintf('Simulated analog signals, x=dots ');
title(my_title); xlabel(' time '); ylabel('Amplitude');

Figure 1:A graph of the given signal


equation

CODES FOR QUANTIZATION OF THE SAMPLED SIGNAL.


freq = 2000; % frequency
mag1 = 3; % magnitude-1
mag2=0.5; % magnitude-2
n = 0:0.0001:0.001 % sample index
% X2 is simulated sampled version of x
X2 = mag1*Sin (2*pi*freq*n) + mag2*Cos (1*pi*freq*n);
my title = sprintf('Simulated analog signals, x=dots ');
title(my_title); xlabel(' time '); ylabel('Amplitude');
% Plot the "sampled" signals
stem(n,x2,'rx');
hold on
stairs(n,x2)
hold of
grid on
my_title = sprintf('Simulated digital signals, x=x y=o');
title(my_title);
xlabel(' samples ');
ylabel('Amplitude');

Figure 2:A graph of quantized


signal

Samples(
ms)
Code
Number
Binary
Codes
Gray
Codes

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

14

11

12

10

111
0
100
1

101
1
111
0

010
0
011
0

000
1
000
1

011
1
010
0

110
0
101
0

101
0
111
1

010
1
011
1

001
1
001
0

1000
1100

According to our design


i)

Sampling rate = (Number of samples)/(sampling Time)


=10/1x10 -3
=10,000samples/second.

ii)
iii)

Quantization step size = 2x(peak amplitude)/(number quantization levels)


= 2x(4)/(16)
= 0.5 steps
Number of samples obtained = 10 samples

iv)
v)

Number of bits represent one sample = 4bits


The overall number of bits = 40bits

You might also like