%
% Example 3.2: Tank with Overflow Weir
%
% Bob Newell, March 1996
%
%-----------------------------------------------------------
%
function y = Overflow_Weir_Tank_Outputs( t, x )
global p
%
% x = [ 1=M ];
% y = [ 1=m_in 2=m_out ];
% p = [ 1=rho 2=A 3=H 4=n 5=L 6=expon ];
%
%-----------------------------------------------------------
  [ n, m ] = size( x );
  y = zeros( n, 2 );
%
  for i = 1:n,
    % inflow rate
    if t(i) < 50,
      y(i,1) = 5;
    else,
      y(i,1) = 10;
    end;
    % weir calculations
    h = x(i,1) / p(1) / p(2) - p(3); 
    y(i,2) = 1.015 * p(1) * p(4) * p(5) * ( h ^ p(6) );
  end;
%-----------------------------------------------------------
% the end!   
