% This program plots the error response for an input
% unit step or
% a ramp with slope Wn or
% a parabola with slope (Wn^2)t
%   Compare to Fig. 6.2-6.4 and 6.7-6.11.

% MODIFY THESE PARAMETERS
% ***********************
Wn = 1     % <- Natural Frequency
zeta = 1;  % <- Damping Factor
% ************************
% Then Go

zeta
go = 2;

while (go ~= 0)
	if (go == 2)
		alpha = 2;
		while ((alpha < 0) | (alpha >1))
			alpha = input('input alpha (0 <= alpha <= 1): ');
		end; % while alpha
	else
		zeta = -1;
		while (zeta <= 0)
			zeta = input('input zeta (>0): ');
		end; % while zeta
	end; % if
	x2 = 2*zeta*Wn;
	x3 = Wn*Wn;
	N0 = 2*(1-alpha)*zeta*Wn;
	num = [1 N0 0]; % <- numerator
	denstep = [1 x2 x3]; % <- denominator for step in
	denramp = [1 x2 x3 0]; % <- denominator for ramp in
	denparab = [1 x2 x3 0 0]; % <- denominator for parabola in
	t = linspace(0,10,50); % <- 0 to 10 with 50 steps
	go = 1;
	while(go == 1)
		ctrl = input('step, ramp, parabola, alpha or zeta change, or quit? Enter first letter: ', 's');
		clf;
		if strcmp(ctrl,'s'),
			step(num,denstep,t);
	 	grid;
		elseif strcmp(ctrl,'r'),
			step(num,denramp,t);
		 grid;
		elseif strcmp(ctrl,'p'),
			t = linspace(0,5,20);
			step(num,denparab,t);
		 grid; 
		elseif strcmp(ctrl,'q'),
		go = 0;
		elseif strcmp(ctrl,'a'),
	 	go = 2;
		elseif strcmp(ctrl,'z'),
		 go = 3;
		end % if
	end % while go == 1
end % while go ~= 0

