0% found this document useful (0 votes)
14 views

All All: If Else End

The document contains code that performs modulation and demodulation of digital signals using techniques like ASK, FSK, and PSK. It defines message signals, carrier signals, performs modulation by multiplying the message and carrier signals, and demodulates the signal by comparing it to the carrier signal. It also contains code that combines two signals into a time-division multiplexed signal and plots the result.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

All All: If Else End

The document contains code that performs modulation and demodulation of digital signals using techniques like ASK, FSK, and PSK. It defines message signals, carrier signals, performs modulation by multiplying the message and carrier signals, and demodulates the signal by comparing it to the carrier signal. It also contains code that combines two signals into a time-division multiplexed signal and plots the result.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

clc;

clear all;
close all;
f=7;
a=1;
n=[1 0 1 1 0 0]
l=length(n);
if n(l)==1
n(l+1)=1
else
n(l+1)=0
end
l1=length(n)
tn=0:l1-1;
subplot(4,1,1)
stairs(tn,n);
title('message')
t=0:0.01:6
% s=length(t)
y1=a*sin(2*pi*f*t);
subplot(4,1,2);
plot(t,y1);
title('carrier')
for i=1:6
for j=(i-1)*100:i*100
if(n(i)==1)
s(j+1)=y1(j+1)
else
s(j+1)=0
end
end
end
subplot(4,1,3)
plot(t,s);
title('ASK')
for i=1:6
for j=(i-1)*100:i*100
if(s(j+1)==y1(j+1))
x(j+1)=1;
else
x(j+1)=0;

end
end
end
subplot(4,1,4);
plot(t,x);
title('demodulation');

clc;
clear all;
close all;
f1=7;
f2=2;
a=1;
n=[1 0 1 1 0 0]
l=length(n);
if n(l)==1
n(l+1)=1
else
n(l+1)=0
end
l1=length(n)
tn=0:l-1;
subplot(5,1,1)
stairs(tn,n);
title('message')
t=0:0.01:6
% s=length(t)
y1=a*sin(2*pi*f2*t);
y2=a*sin(2*pi*f1*t);
subplot(5,1,2);
plot(t,y1);
title('carrier1');
subplot(5,1,3);
plot(t,y1);
title('carrier2');
for i=1:6
for j=(i-1)*100:i*100
if(n(i)==1)
s(j+1)=y1(j+1)

else
s(j+1)=y2(j+1)
end
end
end
subplot(5,1,4)
plot(t,s);
title('FSK')
for i=1:6
for j=(i-1)*100:i*100
if(s(j+1)==y1(j+1))
x(j+1)=1;
else
x(j+1)=0;
end
end
end
subplot(5,1,5);
plot(t,x);
title('demodulation');
clc;
clear all;
close all;
f=7;
a=1;
n=[1 0 1 1 0 0]
l=length(n);
if n(l)==1
n(l+1)=1
else
n(l+1)=0
end
l1=length(n)
tn=0:l1-1;
subplot(4,1,1)
stairs(tn,n);
title('message')
t=0:0.01:6
% s=length(t)

y1=a*sin(2*pi*f*t);
subplot(4,1,2);
plot(t,y1);
title('carrier')
for i=1:6
for j=(i-1)*100:i*100
if(n(i)==1)
s(j+1)=y1(j+1)
else
s(j+1)=-1*y1(j+1)
end
end
end
subplot(4,1,3)
plot(t,s);
title('PSK')
for i=1:6
for j=(i-1)*100:i*100
if(s(j+1)==y1(j+1))
x(j+1)=1;
else
x(j+1)=0;
end
end
end
subplot(4,1,4);
plot(t,x);
title('demodulation');

clear ll;
close all;
x=0:.5:4*pi;
sig1=8*sin(x);
l=length(sig1);
sig2=8*triang(l);
subplot(2,2,1)
plot(sig1);
subplot(2,2,2);
plot(sig2)
subplot(2,2,3)
stem(sig1);
subplot(2,2,4);
stem(sig2)
l1=length(sig1)
l2=length(sig2)
for i=1:l2
sig(1,i)=sig1(i);
sig(2,i)=sig2(i);
end
tdmsig=reshape(sig,1,2*l1);
figure
stem(tdmsig);

You might also like