function [fun,dfun,x] = SolveODEwithShooting(Fun, dyFun, dypFun, BV)
% On input: 
%   Fun, dyFun, and dypFun are the names of function and its partial
%   derivatives. 
%   BV is a data structure that contains
%   BV.a, BV.b: interval of integration
%   BV.alpha, BV.beta: bounday values at BV.a and BV.b
%   BV.t: current t value
% On output
%     x:  points in interval.
%   fun: solution of ODE 
%  dfun: derivative of solution
%
% Written by Ming Gu for Math 128B, Spring 2010
% 
[FunFcn,msg] = fcnchk(Fun,0);
if ~isempty(msg)
    error('InvalidFUN',msg);
end
[dyFunFcn,msg] = fcnchk(dyFun,0);
if ~isempty(msg)
    error('InvalidFUN',msg);
end
[dypFunFcn,msg] = fcnchk(dypFun,0);
if ~isempty(msg)
    error('InvalidFUN',msg);
end
y0  = [BV.alpha;BV.t;0;1];
[Tout, Yout] = ode45(@(x,y)ODEFunfromShooting(x,y,FunFcn, dyFunFcn,dypFunFcn),[BV.a,BV.b],y0);
fun    = Yout(:,1);
dfun   = Yout(:,3);
x      = Tout(:);




