%% Getting Started with LTI Models -- Continuous/Discrete Conversions

%   Copyright 1986-2004 The MathWorks, Inc.
%   $Revision: 1.1.6.1 $  $Date: 2004/08/17 21:33:02 $

%% Continuous/Discrete Conversions

GSC2DConversions_aux(1); % Draw Diagram

%%
% The function C2D converts *TF*, *ZPK*, and *SS*
% models from continuous time to discrete time equivalents.  Conversely,
% the function D2C converts these models from discrete time
% to continuous time equivalents.  Several conversion methods are
% supported, including:
%
% * Zero-order hold
% * First-order hold
% * Tustin approximation (bilinear)
% * Tustin with frequency prewarping
% * Matched poles and zeros
 

%% Performing Continuous/Discrete Conversions
GSC2DConversions_aux(2); % Draw Diagram
  
%%
% You can use these commands to perform basic zero-order hold conversions:
%
% >> sysd = c2d(sysc,Ts);    % Ts = sampling period in seconds
%
% >> sysc = d2c(sysd);
% 
%  You can specify alternative conversion methods with an extra string
%  input
%
% >> sysd = c2d(sysc,Ts,Method);
%
% >> sysc = d2c(sysd,Method);
% 
% where Method can be 'zoh', 'foh', 'tustin', 'prewarp', or 'matched'.
 

%% Continuous-to-Discrete Conversion Example
% For example, you can discretize the continuous-time model
%
sysc = tf([1 0.5 100],[1 5 100]);

%%
% with a 0.1 sec sampling time as follows:

sysd = c2d(sysc,0.1);    % uses zero-order hold

%%
% You can compare the step responses of these systems using the STEP
% command:

GSC2DConversions_aux(3);

step(sysc,'b',sysd,'r')

%%
% Run the "Notch Filter Discretization" demo for a detailed illustration of
% the effect of various discretization methods on the conversion of this
% continuous-time model to its discrete time equivalent:
%
% >> notchdemo


