Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Ask

a=[1 0 1 1 0 0 1 1 1];
t=(0:0.1:160-0.1);
ans=zeros(1,1600);
x=(0:1:8);
y=sin(t);
for i=1:8
for j=1+(200*(i-1)):200*(i)
ans(j)=a(i)*y(j);
end
end
subplot(3,1,1)
stairs(x,a)
axis([0 8 -.5 1.5])
subplot(3,1,2)
plot(t,y)
subplot(3,1,3)
plot(t,ans)
i=2;
result=[];
while i<=1600
if ans(i)== 0
result=[result 0];
else
result=[result 1];
end
i=i+200;
end

disp(result);

fsk

a=[1 0 1 1 0 0 1 1 1];
t=(0:0.1:160-0.1);
ans=zeros(1,1600);
x=(0:1:8);
y1=sin(t);
y2=sin(2*t);
for i=1:8
for j=1+(200*(i-1)):200*(i)
ans(j)=a(i)*y2(j)+abs(1-a(i))*y1(j);
end
end
subplot(4,1,1)
stairs(x,a)
axis([0 8 -.5 1.5])
subplot(4,1,2)
plot(t,y1)
subplot(4,1,3)
plot(t,y2)
subplot(4,1,4)
plot(t,ans)

nrz

input=[1,0,1,1,0,0,0,1,1,0,1];
a=[0,0,0,0,0,0,0,0,0,0,0,0];

for i=1:1:11
if input(i)==1
a(i)=5;
else
a(i)=-5;
end
end
t=(0:1:11);
subplot(6,2,1)
stairs(t,a);
axis([0 11,-8 8])
if input(1)==1
a(1)=5;
else
a(1)=-5;
end
for i=2:1:11
if input(i)==1
a(i)=-a(i-1);
else
a(i)=a(i-1);
end
end
subplot(6,2,2)
stairs(t,a);
axis([0 11,-8 8])
if input(1)==1
a(1)=-5;
else
a(1)=5;
end
for i=2:1:11
if input(i)==0
a(i)=-a(i-1);
else
a(i)=a(i-1);
end
end
subplot(6,2,3)
stairs(t,a);
axis([0 11,-8 8])
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
for i=1:1:11
if input(i)==1
b(2*i-1)=5;
b(2*i)=0;
else
b(2*i-1)=0;
b(2*i)=0;
end
end
t1=(0:0.5:11.5);
subplot(6,2,4)
stairs(t1,b);
axis([0 11,-1.5 7])
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
for i=1:1:11
if input(i)==1
b(2*i-1)=5;
b(2*i)=0;
else
b(2*i-1)=-5;
b(2*i)=0;
end
end
t1=(0:0.5:11.5);
subplot(6,2,5)
stairs(t1,b);
axis([0 11,-8 8])
x=5;
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
for i=1:1:11
if input(i)==1
b(2*i-1)=x;
b(2*i)=0;
x=-x;
else
b(2*i-1)=0;
b(2*i)=0;
end
end
t1=(0:0.5:11.5);
subplot(6,2,6)
stairs(t1,b);
axis([0 11,-8 8])
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
for i=1:1:11
if input(i)==1
b(2*i-1)=5;
b(2*i)=-5;
else
b(2*i-1)=-5;
b(2*i)=5;
end
end
t1=(0:0.5:11.5);
subplot(6,2,7)
stairs(t1,b);
axis([0 11,-8 8])
x=-5;
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
for i=1:1:11
if input(i)==1
b(2*i-1)=x;
b(2*i)=-x;
x=-x;
else
b(2*i-1)=x;
b(2*i)=x;
end
x=-x;
end
t1=(0:0.5:11.5);
subplot(6,2,8)
stairs(t1,b);
axis([0 11,-8 8])
x=-5;
b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
for i=1:1:11
if input(i)==0
b(2*i-1)=x;
b(2*i)=-x;
x=-x;
else
b(2*i-1)=x;
b(2*i)=x;
end
x=-x;
end
t1=(0:0.5:11.5);
subplot(6,2,8)
stairs(t1,b);
axis([0 11,-8 9])

You might also like