%
% Example 3.6: Simple Biological Reactor
%
% Bob Newell, March 1996
%
%-----------------------------------------------------------
%
function y = Simple_Biological_Reactor_Outputs( t, x )
global p
%
% x = [ 1=V 2=Sn 3=Xb ];
% y = [ 1=v_in 2=Sn_in 3=Xb_in 
%       4=v_out 5=Sn_out 6=Xb_out  ];
% p = [ 1=muhat 2=Kn 3=Yb ];
%
%-----------------------------------------------------------
  [ n, m ] = size( x );
  if m == 1,
    x = x';
    n = 1;
  end;
  y = zeros( n, 2 );
%
  for i = 1:n,
    % influent conditions
    y(i,1) = 5;
    if t(i) < 5/24,
      y(i,2) = 400;
    else,
      y(i,2) = 200;
    end; 
    y(i,3) = 100;
    % constant volume
    y(i,4) = y(i,1);
    % well mixed
    y(i,5) = x(i,2);
    y(i,6) = x(i,3);
  end;
%-----------------------------------------------------------
% the end!   
