%
% function for Example 12.3
%
function dxdt = spring_and_damper( t, x )
%
global k;
%
dxdt = zeros( 2, 1 );
% forcing function
if t < 5
   f = -5;
else
   f = 5;
end;
% process itself (spring and damper)
dxdt(1) = x(2);
dxdt(2) = -x(1) - x(2) + f;
% estimator
dxdt(3) = x(4) + k(1) * ( x(1) - x(3) );
dxdt(4) = -x(3) - x(4) + f + k(2) * ( x(1) - x(3) );
%
