All All: If Else End
All All: If Else End
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);