close all;
clear all;
d=[1,0,1,1,0];
for i=1:length(d)
if i>1
if d(i)==1
a(i)=b(i-1);
b(i)=a(i-1);
else
a(i)=a(i-1);
b(i)=b(i-1);
end
else
if d(i)==1
a(i)=2;
b(i)=-2;
else
a(i)=-2;
b(i)=2;
end
end
hold on;
for j=i:0.01:i+0.5
plot(j,a(i),'.-r');
end
for j=i+0.5:0.01:i+1
plot(j,b(i),'.-r');
end
grid on;
end