%
%
function [f1,f2]=bobs_dop0_b(u,s,dt,t,flg)
%
%  s = [x q]'
%
a = [1 0; 1 -2]; b = [-5; 0];
g = eye(size(a))+a*dt;
h = b*dt;
%
x = s(1:2); q = s(3); 
%
if flg == 1
   f1 = [g*x+h*u; q+u*u];  
elseif flg == 2
   f1 = x'*x+q; f2 = [2*x' 1];
elseif flg == 3
    f1 = [g zeros(2,1); zeros(1,2) 2*u]; f2 = [h;  2*u];
end;
      