Untitled
Untitled
data=[0 1 1 0 1 0 ];
v=2;
n=length(data);
Tb=1/Rb;
Ts=Tb/100;
t=0:Ts:Tb-Ts;
T=0:Ts:n*Tb-Ts;
cpulse=[ones(1,length(t)/2) zeros(1,length(t)/2)];
clock=[];
for i=1:n
clock=[clock cpulse];
end
dataplot0=zeros(1,length(t));
dataplot1=ones(1,length(t));
dataplot=[];
UNRZ0=zeros(1,length(t));
UNRZ1=v*ones(1,length(t));
UNRZ=[];
BNRZ0=-v*ones(1,length(t));
BNRZ1=v*ones(1,length(t));
BNRZ=[];
URZ0=zeros(1,length(t));
URZ1=[v*ones(1,length(t)/2) zeros(1,length(t)/2)];
URZ=[];
for i=1:n
if data(i)==0
dataplot=[dataplot dataplot0];
UNRZ=[UNRZ UNRZ0];
BNRZ=[BNRZ BNRZ0];
URZ=[URZ URZ0];
BRZ=[BRZ BRZ0];
else
dataplot=[dataplot dataplot1];
UNRZ=[UNRZ UNRZ1];
BNRZ=[BNRZ BNRZ1];
URZ=[URZ URZ1];
BRZ=[BRZ BRZ1];
end
end
subplot(6,1,1)
plot(T,clock,'linewidth',5)
grid on
axis([0 n*Tb-Ts -0.2 1.1*v])
xlabel('Time axis ','fontsize',15)
ylabel('clock ','fontsize',15)
subplot(6,1,2)
plot(T,dataplot,'linewidth',5)
grid on
axis([0 n*Tb-Ts -1.1*v 1.1*v])
xlabel('Time axis ')
ylabel('data bits ')
subplot(6,1,3)
plot(T,UNRZ,'linewidth',5)
grid on
axis([0 n*Tb-Ts -1.2*v 1.1*v])
xlabel('Time axis ')
ylabel('UNRZ ')
subplot(6,1,4)
plot(T,BNRZ,'linewidth',3)
grid on
axis([0 n*Tb-Ts -1.2*v 1.1*v])
xlabel('Time axis ')
ylabel('BNRZ ')
subplot(6,1,5)
plot(T,URZ,'linewidth',5)
grid on
axis([0 n*Tb-Ts -1.2*v 1.1*v])
xlabel('Time axis ')
ylabel('URZ ')
subplot(6,1,6)
plot(T,BRZ,'linewidth',3)
grid on
axis([0 n*Tb-Ts -1.2*v 1.1*v])
xlabel('Time axis ')
ylabel('BRZ ')