function m = labone(p1,p2,p3)
global A B x0

A=p1;
B=p2;
x0=p3;

solinit = bvpinit(linspace(0,1),@laboneinit);

sol = bvp4c(@laboneode,@labonebc,solinit);

time = sol.x;
state = sol.y(1,:);
adjoint = sol.y(2,:);
control = -(1/B)*sol.y(2,:);
m(1,:) = time;
m(2,:) = state;
m(3,:) = adjoint;
m(4,:) = control;

%--------------------------------------------------------------------------
function dydt=laboneode(t,y)
global A B x0

dydt=[y(1) - (1/B)*y(2)
      -A*y(1) - y(2)];


%--------------------------------------------------------------------------
function res=labonebc(ya,yb)
global A B x0

res=[ya(1) - x0
    yb(2)];

%--------------------------------------------------------------------------
function v=laboneinit(t)
global A B x0

v=[x0
    0.0];
