Professional Documents
Culture Documents
Arkajyoti Saha: Assigned
Arkajyoti Saha: Assigned
NAME - ARKAJYOTI
SAHA
SLOT - L37+L38
clc;
clear all;
close all;
for i=1:length(Xs)
for j=1:L
if Xs(i)<Sx(j+1) % current amplitude will be
checked with next amplitude in SX
Q(i)=Sx(j+1); % above condition is
satisfied the Q=Sx
B( (n*(i-1)+1) : n*i ) = b(j,:); % B for
stream of bits, b is to take corresponding binary
digits
break;
end
end
end
subplot(3,1,2);
stem(Ts,Xs,'r');
hold on;
stem(Ts,Q);
xlabel('time-->');
ylabel('amp-->');
title('Quantisation');
subplot(3,1,3);
stairs(B); % ploting 78 bits
axis([0 78 -2 3]);
xlabel('time-->');
ylabel('amp-->');
title('Encoding');
CODE SIMULATED IN MATLAB
SBWBKJ.m dcs PCM.m ^ 6
1 - clc;
g - clear ali;
3 - close all;
4
5
6 a=5;% Peak Amplitude of the signal
7 fm=2; % Frequency of the sine wave
s — t=e:1/(100*fm):1; % x axis -- e to 1 in steps of 1/2ee; 2e1 samples wil:
g — m=a*sin(2*pi^fm*t); R Continous Time Signal, m is original signal to b‹
0
1 — fs=25;% Sampling frequency
2 Ts=e:1/fs:1; % x axis for sampled signal; 26 samples, 1/fs is sampling 1
3 Xs=a*sin(2*pi*fm*Ts); % Discrete Time signal, Sampled signal with Ts
4 R 25 differnt amplitude lelvels avilable out of 26 levels
5 R it requires 5 bits per levlel
6 R in this program 25 levies will be converted to 8 levies
7 R totally 3 bits per lelvel
8 — subplot(5,1,1);
9 — plot(t,m, ’r’);% plot for Continuous time signal
0 hold on;% keeping next singnal in the same plot
i stem(Ts,Xs,’k’); % Discrete Time signal, ie. Sampled signal
2 Xlabelf 'time--> '):
SBWBKJ.m dcs PCM.m • °f°
Z* - stem(Ts,Xs,'k'); % Discrete Time signal, ie. Sampled signal
22 - xlabel(’time-->');
23 - ylabel('amp-->');
Z4 - title('sampling');
s — legend(’message signal’,’sampled signal');
26
27
33 Ro=str2double(b);
34
35 R B different binary values
36 B=zeros(length(Xs)*n,1); R 26 * 3= 78 bits will the output
37 Q=zeros(length(Xs),l); % Totally 26 amplitude levles in the signal and they are quan
38 Sx=-a:(2*a)/L:a;X Quantized amplitude levels; Toatally 9 values
39
40 - for i=1:length(Xs)
41 - .- for j=1:L
42 if Xs(i)<Sx(j+1) R current amplitude will be checked with next amplitude in
- subplot(3,1,2);
stem(Ts,Xs,’r');
hold on;
stem{Ts,Q);
x1abe1('time--›');
ylabel('amp--›');
title('Quantisation');
— subplot(3,1,3);
- stairs(B); % ploting 78 bits
axis ( [B 78 -2 3] ) ;
S7
5s — subplot(3,1,3);
s9 — stairs(B); X ploting 78 bits
60 - axis([0 78 -2 3]);
6i - xlabel(’time-->');
62 ylabel('amp-->');
63 - title('Encoding');
64
OUTPUT IN MATLAB
2-
* 1
Eo
-1 -
0 10 20 40 60 Z0
time—›