%
%  This program plays with a ZOH in Simulink
%
% Set the sample time
%
  Ts = 0.05;
%
%  set the final time
%
  Tf = 5;
%
%  set the continuous-time transfer function
%
  Gp = tf(1,[1 2 0.1])
  [num_s, den_s] = tfdata(Gp,'v');
%
%  convert to a discrete-time transfer function using ZOH
%
  Gp_z = c2d(Gp,Ts,'zoh')
  [num_Gp_z,den_Gp_z] = tfdata(Gp_z,'v');
%
%  set the discrete-time controller
%
  Gc_z = 5.9*tf([1 -0.982],[1 -1], Ts)
  [num_Gc_z, den_Gc_z] = tfdata(Gc_z,'v');
%
%  run the simulation
%
  sim('zoh_files');
%
%  plot the transfer function results
%
  figure;
  [tz_s,yz_s]  = stairs(t_z, y_z);
  [tzoh_s,yzoh_s] = stairs(t_z,ys);
  plot(tz_s, yz_s,'r.-', tzoh_s, yzoh_s,'b:'); grid;
  legend('Discrete-Time Plant','Continuous-Time Plant');
  xlabel('Time (sec)'); ylabel('Output y(n)');
