%% Tustin Continuous s-Plane to Discrete z-Plane transforms
%% Create plant and compute transforms

A = [-1 1; 0 -2]; 
B = [1 0; 1 1];  
C = [1 0; 0 1];   
D = [0 0; 0 0]; 
sys = ss(A,B,C,D);                   % ANALOG
Ts = 0.05;  % sample time
syst = c2d(sys,Ts,'tustin');         % Tustin 
sysp = c2d(sys,Ts,'prewarp',40);     % Pre-warped Tustin 
sysb = bilin(sys,1,'BwdRec',Ts);     % Backward Rectangular
sysf = bilin(sys,1,'FwdRec',Ts);     % Forward Rectangular

%
%% Plot system and transforms

w = logspace(-2,3,50); % frequencies to plot
sigma(sys,syst,sysp,sysb,sysf,w); 
legend('sys','syst','sysp','sysb','sysf','Location','SouthWest')

% Copyright 2015 The MathWorks, Inc.