Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

DIGITAL COMMUNICATION SYSTEMS

LAB TASK-1(SOFTWARE)
FACULTY: PROF. RAJESH A

SUBMITTED BY:
REG NO: 17BEC0423
NAME: JUGAL SUGGALA

SAMPLING
clc; clear all; T = 1; fs1=100; t = 0:1/fs1:T;
n1=t*fs1; f = 5; xa = cos(2*pi*f*t);
figure('name','17BEC0423'); subplot(3,2,1)
stem(n1,xa); xlabel('Time');
ylabel('Amplitude'); title('Over sampled
signal');
subplot(3,2,2); plot(t,xa); xlabel('Time');
ylabel('Amplitude'); title('Reconstructed
signal');
fs2=10; t1 = 0:1/fs2:T;
n2=t1*fs2;
xa1=cos(2*pi*f*t1);
subplot(3,2,3); stem(n2,xa1);
xlabel('Time');
ylabel('Amplitude');
title('Critically sampled
signal');
subplot(3,2,4); plot(t1,xa1); xlabel('Time');
ylabel('Amplitude'); title('Reconstructed
signal');
fs3=8; t2 = 0:1/fs3:T; n3=t2*fs3;
xa2=cos(2*pi*f*t2); subplot(3,2,5)
stem(n3,xa2); xlabel('Time');
ylabel('Amplitude'); title('Under sampled
signal');
subplot(3,2,6); plot(t2,xa2); xlabel('Time');
ylabel('Amplitude'); title('Reconstructed
signal');

OUTPUT:

QUANTIZATION
QUANTIZATION FUNCTION:
function y=uquant(x,n) del=((max(max(x))-
(min(min(x)))))/(n-1); r=(x-min(min(x)))/del; r=round(r);
y=r*del+min(min(x));
CODE: clc, clear all; close all; t=0:.001:1;
y=2*sin(2*pi*t); figure('name','17BEC0423');
subplot(3,1,1) plot(y) xlabel('Time ----->');
ylabel('Amplitude ----->'); title('Input Message Signal');
q1=uquant(y,4); subplot(3,1,2) plot(q1) xlabel('Time ----
->'); ylabel('Amplitude ----->'); title('Quantized Signal
with L = 4'); q2=uquant(y,32); subplot(3,1,3) plot(q2)
xlabel('Time ----->'); ylabel('Amplitude ----->');
title('Quantized Signal with L = 32');
OUTPUT:

LINE CODING
CODE:
clc; close all; clear all;
x=[1 0 1 1 0 1];
nx=size(x,2); sign=1;
i=1;
figure('name','17BEC0423'); while i<nx+1 t =
i:0.001:i+1-0.001; if(x(i)==1)
unipolar_code=square(t*2*pi,100);
polar_code=square(t*2*pi,100);
bipolar_code=sign*square(t*2*pi,100); sign=sign*-1;
manchester_code=square(t*2*pi,50); else
unipolar_code=0; polar_code=-square(t*2*pi,100);
bipolar_code=0; manchester_code=-square(t*2*pi,50);
end subplot(4,1,1); plot(t,unipolar_code);
ylabel('unipolar code'); hold on; grid on; axis([1 10 -2
2]); subplot(4,1,2); plot(t,polar_code); ylabel('polar
code'); hold on; grid on; axis([1 10 -2 2]);
subplot(4,1,3); plot(t,bipolar_code); ylabel('bipolar
code'); hold on; grid on; axis([1 10 -2 2]);
subplot(4,1,4); plot(t,manchester_code);
ylabel('manchester code'); hold on; grid on; axis([1 10 -
2 2]); i=i+1;
end

OUTPUT:
TASKS

Generate the basic signals:


CODE:
syms id figure('name','17BEC0423') x
= -1:0.1:1; y = dirac(x); id=y==Inf;
y(id)=1; n=-5:1:5; y2=heaviside(n);
y3=(2*y2)-1;
y4=heaviside(n+2)-heaviside(n-2); n1=0:1:19;
f0=100;
fs=1000; y5=sin(2*pi*(f0/fs)*n1);
n2=linspace(-50,50,30); Ts=0.1;
y6=sinc(Ts*n2); subplot(3,3,1) stem(x,y)
xlabel('time') ylabel('Amplitude')
title('Impulse function') subplot(3,3,2)
stem(n,y2) xlabel('time') ylabel('Amplitude')
title('Unit step function') subplot(3,3,3)
stem(n,y3) xlabel('time') ylabel('Amplitude')
title('Sign function') subplot(3,3,4) stem(n,y4)
xlabel('time') ylabel('Amplitude')
title('Rectangle function') subplot(3,3,5)
stem(n1,y5) xlabel('time') ylabel('Amplitude')
title('Sine function') subplot(3,3,6)
stem(n2,y6) xlabel('time') ylabel('Amplitude')
title('Sine cardinal function')
OUTPUT:
Generate the signals using “RZ”
CODE:
clc; close all; clear all;
figure('name','17BEC0423') x=[1 0 1 1
0 1]; nx=size(x,2); sign=1; i=1; while
i<nx+1 t = i:0.001:i+1-0.001; if
x(i)==1
unipolar_code=(square(t*2*pi,100)-square(t*2*pi,50))/2;
polar_code=(square(t*2*pi,100)-square(t*2*pi,50))/2;
bipolar_code=(sign/2)*(square(t*2*pi,100)square(t*2*pi,50)); sign=sign*-1;
manchester_code=square(t*2*pi,50); else unipolar_code=0; polar_code=(-
square(t*2*pi,100)+square(t*2*pi,50))/2; bipolar_code=0; manchester_code=-
square(t*2*pi,50); end subplot(4,1,1); plot(t,unipolar_code); ylabel('unipolar code');
hold on; grid on; axis([1 10 -1 1]); subplot(4,1,2); plot(t,polar_code); ylabel('polar
code'); hold on; grid on; axis([1 10 -1 1]); subplot(4,1,3); plot(t,bipolar_code);
ylabel('bipolar code'); hold on; grid on; axis([1 10 -1 1]); subplot(4,1,4);
plot(t,manchester_code); ylabel('manchester code'); hold on; grid on; axis([1 10 -2 2]);
i=i+1;
end

OUTPUT:

You might also like