% phase delay demo script
close all;  clc;    clear all;

% basic system & delay
G = zpk([],[-0.286 -0.286 -0.286], 10);     % system transfer function
dly = 2;    % <--- enter delay in seconds here

% phase from basic system
wout = logspace(-2,2,20000);
[mag,phase,w] = bode(G,wout);
ph = squeeze(phase);
semilogx(w,ph), grid on, hold all

% phase from time delay delay
L = -dly * w;
semilogx(w,L), 

% plot phase sum
X = ph + L;
semilogx(w,X)
legend('Basic phase','Delay phase','Total phase','Location','SouthWest')

% end of file
