%Develop error ramp response by standard matrix procedure
%  alpha = 1, zeta = 0.5, Wn = 1
%  Ramp Input

% Generate vector of computation times:
inc = .05; %sampling period
ending = 10; % Student Matlab limits ending/inc to 1024 max
last = 1 + ending/inc; % index of last data points
t = linspace(0,ending,last); % linear sequence of times
dt = t(2) - t(1); % time increment

%generate input ramp vector:
for i = 1:last,
	u(i) = (i-1)*inc;
end % generation of input vector

clf; % clear previous graphs;

NUM = [1 0 0]; % for error response, as before
DEN = [1 1 1]; % denstep from ErTrans
[a,b,c,d] = tf2ss(NUM,DEN); % get elements of dynamic matrix equation
[Phi, Gamma] = c2d(a,b,dt); % get values for use in solution equation
x = ltitr(Phi,Gamma,u'); % state variable solution for each value of t
y = c*x'+d*u; % outputs

plot(t,y) 
grid
title('Time Response, Error, Ramp Input')
xlabel('seconds')
ylabel('radians')

		
		

