clc;clear;
tv    = 0;
tsim  = 100;
tstep = [10;20;50]; 
dstep = [4;5;6];

nd = numel(dstep);
d  = zeros(2*nd+1,nd);

for  i = 1:nd
     tv         = [tv ones(1,2)*tstep(i)];     
     d(2*i,i)   = dstep(i);
     d(2*i+1,i) = dstep(i);
end



%tv     = [tv tsim]
%d(end) = dstep(end)
ts     = timeseries(d,tv);
t0 = [10;20;30]; 
tf = t0+5;
for i =1:nd
     t  = [0 t0(i) t0(i) tf(i)];
     d2 = [0 0 dstep(i) dstep(i)];
     ts2i  = timeseries(d2',t);     
end