clc
clear all
close all
n=input('enter the number of bits')
m=mod(randperm(n),2) %binary data
t=['the binary data is ',num2str(m)]
c=input('enter your choice 1.unipolar nrz 2.polar nrz 3.unipolar rz 4.manchester')
switch c
case 1
for i=1:1:n
s((i-1)*100+1:i*100)=m(i)
end
case 2
for i=1:1:n
if m(i)==1
m(i)=1
else
m(i)=-1
end
end
for i=1:1:n
s((i-1)*100+1:i*100)=m(i)
end
case 3
for i=1:1:n
s(1+100*(i-1):50*((2*i)-1))=m(i)
s(1+50*((2*i)-1):100*i)=0
end
case 4
for i=1:1:n
if m(i)==1
m(i)=1
else
m(i)=-1
end
end
for i=1:1:n
s(1+100*(i-1):50*((2*i)-1))=m(i)
s(1+50*((2*i)-1):100*i)=-m(i)
end
otherwise
disp('invalid choice')
end
plot(s)
gtext(t)
switch c
case 1
gtext('unipolar nrz signaling')
case 2
gtext('polar nrz signaling')
case 3
gtext('unipolar rz signaling')
otherwise
gtaxt('manchester signaling')
end
clear all
close all
n=input('enter the number of bits')
m=mod(randperm(n),2) %binary data
t=['the binary data is ',num2str(m)]
c=input('enter your choice 1.unipolar nrz 2.polar nrz 3.unipolar rz 4.manchester')
switch c
case 1
for i=1:1:n
s((i-1)*100+1:i*100)=m(i)
end
case 2
for i=1:1:n
if m(i)==1
m(i)=1
else
m(i)=-1
end
end
for i=1:1:n
s((i-1)*100+1:i*100)=m(i)
end
case 3
for i=1:1:n
s(1+100*(i-1):50*((2*i)-1))=m(i)
s(1+50*((2*i)-1):100*i)=0
end
case 4
for i=1:1:n
if m(i)==1
m(i)=1
else
m(i)=-1
end
end
for i=1:1:n
s(1+100*(i-1):50*((2*i)-1))=m(i)
s(1+50*((2*i)-1):100*i)=-m(i)
end
otherwise
disp('invalid choice')
end
plot(s)
gtext(t)
switch c
case 1
gtext('unipolar nrz signaling')
case 2
gtext('polar nrz signaling')
case 3
gtext('unipolar rz signaling')
otherwise
gtaxt('manchester signaling')
end