function [Atau,Btau,Dtau] = ss4delay(tau,dt)
% SS4DELAY
% [At,Bt,Dt] = ss4delay(tau,dt)
% Constructing a State Space model for a time delay, tau.
% On Input
% tau - time delay
% dt  - sampling time
% On Output
% At,Bt,Dt - State space model matrices for the delay, y(t)=t(t-tau)

nt=floor(tau/dt);

Atau=[zeros(1,nt);eye(nt-1,nt)];
Btau=[1;zeros(nt-1,1)];
Dtau=[zeros(1,nt-1),1];