% Script e7 Time response to piecewise constant input
  clear % removes all variables from the workspace
  zz = [-5; i; -i]	% generate G(s) in ZPK form
  pp = [-1; -2; -2; -3]
  kk = 1
  G = zpk(zz,pp,kk)
  pause
  t = [0:0.1:10]; % generate time vector
  impulse(G,t) % impulse response of G
  pause
  [numG,denG] = tfdata(G,'v');
  G1 = tf([1 5],denG); % remove complex zeros from numG
  impulse(G1,t)
  grid, title('impulse response with zeros factored out')
  pause
  e = sin(t); % input signal with a frequency of 1 rad/s
  y = lsim(G,e,t); % simulate the time response of G with input e
  plot(t, y), grid, title('time response to sinusoidal input')
  xlabel('time'), ylabel('amplitude')
  
  