You are on page 1of 27

COMMUNICATION SYSTEMS-I

(LAB MANUAL)

Muhammad Azhan Shaikh


50854
ELECTRONICS(18)

Submitted to:
Ms Fatima Haroon
TASK#01
Object: To perform basic mathematical operations on matlab.
Code/Output:
>>A=5;

>>B=2;

>>A+B;

>>ANS=7

>>A-B;

>>ANS=3

>>A*B;

>>ANS=10

>>A/B;

>>ANS=5/2

>>A^B;

>>ANS=25

Result: The task has been performed and its output is also written.
TASK#02
Object:To plot a sine wave on matlab.
Code:
clc
close all
clear all
%%declaration
fm=1000
t=0:1/fm:1
%%formula
a=sin(2*pi*fm*t)
%%figure
figure()
plot(t,a)
xlabeltime(s)
ylabelamp(v)
title ('sine wave')
TASK#03
Object: Response of IR transmission and reception
Components required:
 IR transmitter
 IR receiver
 Led
 Resistors

Theory:
IR sensor:
IR sensor is an electronic device, that emits the light in order to sense some object of the
surroundings. Ir sensor have transmitter as well as reciever. An IR sensor can measure the heat of an
object as well as detects the motion.

IR Transmitter:
IR Transmitter is just an IR led.

IR Reciever:
IR receiver is a photodiode.

Circuit diagram:

Observation:
It was observed that after providing voltages ir transmitter transmits rays which was received by
reciever and this was proved that when an obstacle comes in between transmitter and receiver the led
was glown which shows that there was some link between transmitter and receiver which was
disturbed .In this way an IR sensor can detect any object or it's distance can also be observed by the
reflection of IR rays when striking with an object.

Result:
Behaviour of IR sensor has been observed.
TASK#04
Object: To plot a modulated signal DSBSC in time domain on matlab.

Code:
Clc

clear all

%%declaration
fs=1000;
t=0:1/fs:1;
fm=10;
fc=100;
%%formula
message=cos(2*pi*fm*t)
carrier=cos(2*pi*fc*t)
mod=message.*carrier
%%figure
figure()
subplot(3,1,1)
plot(t,message)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(t,carrier)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(t,mod)
xlabel time(s)
ylabel amp(v)
title('modulated signal')

Result: The task has been performed and the waveform has been plotted.
TASK#05
Object: To plot a modulated signal DSBSC in frequency domain on matlab.

Code:
clc
clear all
%%declaration
fs=1000;
t=0:1/fs:1;
n=1024;
f=-n/2:n/2-1;
fm=10;
fc=100;
%%formula
message=cos(2*pi*fm*t)
message1=abs(fft(message,n))
m2=fftshift(message1)
carrier=cos(2*pi*fc*t)
carrier1=abs(fft(carrier,n))
c2=fftshift(carrier1)
mod=message.*carrier
mod1=abs(fft(mod,n))
mod2=fftshift(mod1)
%%figure
figure('Name','Time Domain')
subplot(3,1,1)
plot(t,message)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(t,carrier)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(t,mod)
xlabel time(s)
ylabel amp(v)
title('modulated signal')
figure('Name','Frequency Domain')
subplot(3,1,1)
plot(f,m2)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(f,c2)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(f,mod2)
xlabel time(s)
ylabel amp(v)
title('modulated signal')

Result: The task has been performed and the waveform has been plotted.
TASK#06
Object: To plot a modulated signal SSBSC in time domain on matlab.

Code:
clc
clear all
%%declaration
fs=1000;
t=0:1/fs:1;
fm=10;
fc=100;
%%formula(msg direct and carrier at 90)
message1=sin(2*pi*fm*t)
carrier1=sin(2*pi*fc*t+(pi/2))
mod1=message1.*carrier1
%%formula(msg at 90 and carrier direct)
message2=sin(2*pi*fm*t+(pi/2))
carrier2=sin(2*pi*fc*t)
mod2=message2.*carrier2
%%figure(msg direct and carrier at 90)
figure()
subplot(3,1,1)
plot(t,message1)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(t,carrier1)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(t,mod1)
xlabel time(s)
ylabel amp(v)
title('modulated signal')
%%figure(msg direct and carrier at 90)
figure()
subplot(3,1,1)
plot(t,message2)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(t,carrier2)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(t,mod2)
xlabel time(s)
ylabel amp(v)
title('modulated signal')

Result: The task has been performed and the waveform has been plotted.
TASK#07
Object: To plot a modulated signal SSBSC in frequency domain on matlab.

Code:
clc
clear all
%%declaration
fs=1000;
t=0:1/fs:1;
fm=10;
fc=100;
n=1024;
f=-n/2:n/2-1;
%%formula(msg direct and carrier at 90)
message1=sin(2*pi*fm*t)
m1=abs(fft(message1,n))
m2=fftshift(m1)
carrier1=sin(2*pi*fc*t+(pi/2))
c1=abs(fft(carrier1,n))
c2=fftshift(c1)
mod1=message1.*carrier1
modu1=abs(fft(mod1,n))
modu2=fftshift(modu1)
%%formula(msg at 90 and carrier direct)
message2=sin(2*pi*fm*t+(pi/2))
m3=abs(fft(message2,n))
m4=fftshift(m3)
carrier2=sin(2*pi*fc*t)
c3=abs(fft(carrier2,n))
c4=fftshift(c3)
mod2=message2.*carrier2
modu3=abs(fft(mod2,n))
modu4=fftshift(modu3)
%%figure Time Domain
figure('Name','Time Domain')
subplot(3,2,1)
plot(t,message1)
xlabel time(s)
ylabel amp(v)
title('message signal 1')
subplot(3,2,3)
plot(t,carrier1)
xlabel time(s)
ylabel amp(v)
title('carrier signal 1')
subplot(3,2,5)
plot(t,mod1)
xlabel time(s)
ylabel amp(v)
title('modulated signal 1')
subplot(3,2,2)
plot(t,message2)
xlabel time(s)
ylabel amp(v)
title('message signal 2')
subplot(3,2,4)
plot(t,carrier2)
xlabel time(s)
ylabel amp(v)
title('carrier signal 2')
subplot(3,2,6)
plot(t,mod2)
xlabel time(s)
ylabel amp(v)
title('modulated signal 2')
%%figure Frequency Domain
figure('Name','Frequency Domain')
subplot(3,2,1)
plot(f,m2)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,2,3)
plot(f,c2)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,2,5)
plot(f,modu2)
xlabel time(s)
ylabel amp(v)
title('modulated signal')
subplot(3,2,2)
plot(f,m4)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,2,4)
plot(f,c4)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,2,6)
plot(f,modu4)
xlabel time(s)
ylabel amp(v)
title('modulated signal')
Result: The task has been performed and the waveform has been plotted.
TASK#08
Object: To plot a modulated signal DSBFC(ideal) in time domain on matlab.

Code:
clc
clear all
%%declaration
fs=1000;
t=0:1/fs:1;
fm=10;
fc=100;
am=5;
ac=5;
%%formula
message=am*sin(2*pi*fm*t)
carrier=ac*sin(2*pi*fc*t)
mod=(message+ac).*carrier
%%figure
figure()
subplot(3,1,1)
plot(t,message)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(t,carrier)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(t,mod)
xlabel time(s)
ylabel amp(v)
title('modulated signal')

Result: The task has been performed and the waveform has been plotted.
TASK#09
Object: To plot a modulated signal DSBFC(under) in time domain on matlab.

Code:
clc
clear all
%%declaration
fs=1000;
t=0:1/fs:1;
fm=10;
fc=100;
am=2;
ac=5;
%%formula
message=am*sin(2*pi*fm*t)
carrier=ac*sin(2*pi*fc*t)
mod=(message+ac).*carrier
%%figure
figure()
subplot(3,1,1)
plot(t,message)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(t,carrier)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(t,mod)
xlabel time(s)
ylabel amp(v)
title('modulated signal')

Result: The task has been performed and the waveform has been plotted.
TASK#10
Object: To plot a modulated signal DSBFC(over) in time domain on matlab.

Code:
clc
clear all
%%declaration
fs=1000;
t=0:1/fs:1;
fm=10;
fc=100;
am=7;
ac=5;
%%formula
message=am*sin(2*pi*fm*t)
carrier=ac*sin(2*pi*fc*t)
mod=(message+ac).*carrier
%%figure
figure()
subplot(3,1,1)
plot(t,message)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(t,carrier)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(t,mod)
xlabel time(s)
ylabel amp(v)
title('modulated signal')

Result: The task has been performed and the waveform has been plotted.
TASK#11
Object: To plot a modulated signal DSBFC(over) in frequency domain on matlab.

Code:
clc
clear all
%%declaration
fs=1000;
t=0:1/fs:1;
fm=10;
fc=100;
am=7;
ac=5;
n=1024;
f=-n/2:n/2-1;
%%formula
message=am*sin(2*pi*fm*t)
message1=abs(fft(message,n))
m2=fftshift(message1)
carrier=ac*sin(2*pi*fc*t)
carrier1=abs(fft(carrier,n))
c2=fftshift(carrier1)
mod=(message+ac).*carrier
mod1=abs(fft(mod,n))
mod2=fftshift(mod1)
%%figure
figure('Name','Time Domain')
subplot(3,1,1)
plot(t,message)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(t,carrier)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(t,mod)
xlabel time(s)
ylabel amp(v)
title('modulated signal')
figure('Name','Frequency Domain')
subplot(3,1,1)
plot(f,m2)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(f,c2)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(f,mod2)
xlabel time(s)
ylabel amp(v)
title('modulated signal')

Result: The task has been performed and the waveform has been plotted.
TASK:12

Object: To plot a modulated signal DSBFC(under) in frequency domain on


matlab.

Code:
clc
clear all
%%declaration
fs=1000;
t=0:1/fs:1;
fm=10;
fc=100;
am=2;
ac=5;
n=1024;
f=-n/2:n/2-1;
%%formula
message=am*sin(2*pi*fm*t)
message1=abs(fft(message,n))
m2=fftshift(message1)
carrier=ac*sin(2*pi*fc*t)
carrier1=abs(fft(carrier,n))
c2=fftshift(carrier1)
mod=(message+ac).*carrier
mod1=abs(fft(mod,n))
mod2=fftshift(mod1)
%%figure
figure('Name','Time Domain')
subplot(3,1,1)
plot(t,message)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(t,carrier)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(t,mod)
xlabel time(s)
ylabel amp(v)
title('modulated signal')
figure('Name','Frequency Domain')
subplot(3,1,1)
plot(f,m2)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(f,c2)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(f,mod2)
xlabel time(s)
ylabel amp(v)
title('modulated signal’)

Result: The task has been performed and the waveform has been plotted.
TASK:13

Object: To plot a modulated signal DSBFC(ideal) in frequency domain on matlab.

Code:
clc
clear all
%%declaration
fs=1000;
t=0:1/fs:1;
fm=10;
fc=100;
am=5;
ac=5;
n=1024;
f=-n/2:n/2-1;
%%formula
message=am*sin(2*pi*fm*t)
message1=abs(fft(message,n))
m2=fftshift(message1)
carrier=ac*sin(2*pi*fc*t)
carrier1=abs(fft(carrier,n))
c2=fftshift(carrier1)
mod=(message+ac).*carrier
mod1=abs(fft(mod,n))
mod2=fftshift(mod1)
%%figure
figure('Name','Time Domain')
subplot(3,1,1)
plot(t,message)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(t,carrier)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(t,mod)
xlabel time(s)
ylabel amp(v)
title('modulated signal')
figure('Name','Frequency Domain')
subplot(3,1,1)
plot(f,m2)
xlabel time(s)
ylabel amp(v)
title('message signal')
subplot(3,1,2)
plot(f,c2)
xlabel time(s)
ylabel amp(v)
title('carrier signal')
subplot(3,1,3)
plot(f,mod2)
xlabel time(s)
ylabel amp(v)
title('modulated signal')

Result: The task has been performed and the waveform has been plotted.
TASK#14
Object: To modulate and demodulate an audio signal on matlab with waveform
plotted.

Code:
clc

clear all

[y,fs] = audioread('C:\Users\John\Desktop\y2mate.com - El Risitas Laugh Meme


template.mp3');

fc=2000;

fs=50000;

freqdev=1500;

ac=10;

t=(linspace(0,length(y)/fs,length(y)));

carrier=ac*sin(2*pi*fc*t);

m = fmmod(y,fc,fs,freqdev);

d = fmdemod(m,fc,fs,freqdev);

sound(d,fs);

figure('name','time domain');

subplot(4,1,1)

plot(t,y);

xlabel('time');ylabel('signal');

title('main voice');

subplot(4,1,2)
plot(t,carrier);

xlabel('time');ylabel('signal');

title('carrier');

subplot(4,1,3)

plot(t,m);

xlabel('time');ylabel('signal');

title('modulated voice');

subplot(4,1,4)

plot(t,d);

xlabel('time');ylabel('signal');

title('demodulated voice');

f=linspace((-fs/2),(fs/2),length(t));

c=abs(fftshift(fft(carrier)));

p=abs(fftshift(fft(y)));

q=abs(fftshift(fft(m)));

r=abs(fftshift(fft(d)));

figure('name','frequency domain');

subplot(3,1,3)

plot(f,p);

xlabel('frequency');ylabel('signal');

title('main voice F');

subplot(3,2,1)

plot(f,q);
xlabel('frequency');ylabel('signal');

title('modulated voice F');

subplot(3,2,3)

plot(f,r);

xlabel('frequency');ylabel('signal');

title('demodulated voice F');

subplot(3,2,4)

plot(f,carrier);

xlabel('frequency');ylabel('signal');

title('carrier');
Result: The task has been performed,audio has been observed and the waveform
has been plotted.
INDEX
S.NO TASK DATE SIGN

1 21-12-23
To perform basic mathematical
operations on matlab.

2 28-12-23
To plot a sine wave on matlab.

3 15-11-23
Response of IR transmission and reception

4 04-01-23
To plot a modulated signal DSBSC in time
domain on matlab.

5 25-01-23
To plot a modulated signal DSBSC in freq
domain on matlab.

6 22-01-23
To plot a modulated signal SSBSC in time
domain on matlab.

7 22-01-23
To plot a modulated signal SSBSC in freq
domain on matlab.

11-01-23
To plot a modulated signal
8 DSBFC(ideal) in time domain on
matlab.
9 11-01-23
To plot a modulated signal
DSBFC(under) in time domain on
matlab.
10 To plot a modulated signal 11-01-23
DSBFC(over) in time domain on
matlab.

11 To plot a modulated signal 11-01-23


DSBFC(over) in freq domain on
matlab.

12 To plot a modulated signal 11-01-23


DSBFC(under) in freq domain on
matlab.

13 To plot a modulated signal 11-01-23


DSBFC(ideal) in freq domain on
matlab.
14 To modulate and demodulate an 15-03-23
audio signal on matlab with
waveform plotted

You might also like