% Script fig03_9.m; control of double-integrator plant with
% on-off logic using hysteresis and deadzone (`Schmitt trigger');
% 5/96, 1/01, 5/28/05
%
N=20000; tf=200; dt=tf/N; z=pi/180; Qo=3*z; tau=5; alo=0*z;
al1=3*z; t=dt*[0:N]; th(1)=7.5*z; u(1)=1; q(1)=0;
for i=1:N
th(i+1)=th(i)+dt*q(i);
u(i+1)=schmitt(th(i)+tau*q(i),u(i),alo,al1);
q(i+1)=q(i)-dt*Qo*u(i+1);
end
%
figure(1); clf; plot(th/z,q/z,[.5 20.5],[.5 -3.5],...
'--',[-1.5 18.5],[.5 -3.5],'--',[-3.5 16.5],[.5 -3.5],...
'--',[-5.5 14.5],[.5 -3.5],'--'); axis([-3 8 -1.5 .5])
grid; xlabel('\theta (deg)'); ylabel('dot\theta (deg/sec)')