%
%  compare the step response of the pendulum with the model
%
  data = load('input_10_degree_step');
  t = data(:,2);
  phi = data(:,4);
  Ts = t(3)-t(2);  
%
%  determine how many samples to use
%
  Tmax = 2.0;  % the last time to look at
  temp = find(t>=Tmax);
  N = temp(1);
  t = t(1:N);
  phi = phi(1:N);
%
%  enter the continuous-time transfer function
%
  z = 0.0511;
  wn = 9.3317;
  K = 1.329;
  Gp_continuous = tf(K*[1 0 0],[1 2*z*wn wn*wn]);
%
%  convert to discrete-time transfer function
%
  Delay = tf(1,[1 0 0],Ts);
  Gp_discrete = c2d(Gp_continuous, Ts)
  Gp_discrete = Gp_discrete*Delay;
%
%  determine the input
%
  A = 10*pi/180;  % input amplitude in radians
  u = A*ones(1,length(t));
%
%  determine the output
%
  y = lsim(Gp_discrete, u, t);
%
%  now plot the estimated output and the real output
%
  figure;
  orient landscape
  plot(t,y,'k',t,phi,'r','Linewidth',1.5); grid; legend('Estimated','Measured');
  ylabel(' \phi (rad)'); xlabel('Time (sec)');
  title('10 degree step input');
