function steps(b,a,Kmax,T)
%    steps(b,a,Kmax,T)
% plots a root locus diagram and a few step responses for the
% closed loop transfer functions
%    G(s)=G*B(s)/(A(s)+KB(s))
% for k in the range 0 <= K <= Kmax and 0 <= t <= T.
% The gain g is chosen to achieve unity DC response.
	figure(1),clf
	subplot(2,2,1),rlocus(b,a),
	L=256;ts=T/L;fs=1/ts;t=ts*[0:L-1];
	n=length(a);m=length(b);hh=[];
	for K=(Kmax/4)*[0:4]
		g=(a(n)+K*b(m))/b(m);
		aa=a+[zeros(1,n-m),K*b];
		[bz,az]=impinvar(b,aa,fs);  % get the digital filter
		bz=real(bz);az=real(az);    % eliminates error messages   
		hh=[hh;g*ts*filter(bz,az,ones(1,L))];
	end
	mx=max(max(hh));mn=min(min(hh));d=.05*(mx-mn);
	subplot(2,1,2)
	plot(t,hh)
	axis([0, T, mn-d, mx+d])
	title('step responses')
