%% Time-Delay Approximation in Continuous-Time Open-Loop Model
%% Create model of open-loop system

s = tf('s');
P = exp(-2.6*s)/(s^2+0.9*s+1);

%
%% Compute first-order Pade approximation

Pnd1 = pade(P,1)

%
%% Compare frequency responses

h = bodeoptions;
h.PhaseMatching = 'on';
bodeplot(P,'-b',Pnd1,'-.r',{0.1,10},h)
legend('Exact delay','First-Order Pade','Location','SouthWest')

%
%% Increase approximation order

Pnd3 = pade(P,3);

%
%% Compare new frequency responses

bodeplot(P,'-b',Pnd3,'-.r',Pnd1,':k',{0.1 10},h)
legend('Exact delay','Third-Order Pade','First-Order Pade',...
       'Location','SouthWest')

%
%% Compare time domain responses

stepplot(P,'-b',Pnd3,'-.r',Pnd1,':k')
legend('Exact delay','Third-Order Pade','First-Order Pade',...
       'Location','Southeast')

% Copyright 2015 The MathWorks, Inc.