%
% Example 3.6: DO Controller
%
% Bob Newell, March 1996
%
%-----------------------------------------------------------
% parameters
Ka = 2;
So_sat = 10;
yd = 3;
uo = 1;
Kc = 2;
taui = 0.01;
%
global p
p = [ Ka So_sat yd uo Kc taui ];
%-----------------------------------------------------------
% initial states
M = 1;
Ss = 200;
So = 3;
z = 0;
%
xo = [ M Ss So z ];
%-----------------------------------------------------------
% integrate the state equation
to = clock;
[ t, x ] = ode45( 'DO_Controller', [0 1], xo );
etime( clock, to )
%-----------------------------------------------------------
% evaluate the outputs
y = DO_Controller_Outputs( t, x ); 
%-----------------------------------------------------------
% plot the results
figure;
hax = plotyy( 24*t, y(:,7), 24*t, y(:,[3 6]) );
axesyy( hax, [ 0 24 -15 10 0 12 ], ...
   'Time in hours', ...
   'Air flowrate in m^3/hr', ...
   'Oxygen in mg/l', 2, ...
   [ 0 5 10 ], [ 0 2 4 6 ] );
%
h = text( 6, -12, 'Inlet' );
set( h, 'fontsize', 16 );
h = text( 6, -7.8, 'Outlet' );
set( h, 'fontsize', 16 );
%
%-----------------------------------------------------------
% the end!   
