%Solve BVP using starting guess and solution of a nonlinear equation.
%for simple ODE y''= 6*t, for a=0<t<b=1
%and for boundary conditions y(a)=1 and y(b)=1.5

function [] = bvp_nonlinear(guess);
x = fzero(@bvpx_nonlinear, guess) %Find zero of a function of one variable
return ;

% Solve nonlinear equation f that incorporate the solution of IVP
function f = bvpx_nonlinear(x);
    a=0; b=1;
    ya=1; yb=1.5;
    y0=[ya, x]      %Initial value for IVP
    [T,Y] = ode45(@def_ODE,[a b],y0); %Solve IVP for ODE, T-time, Y-solution
    s=size(Y)
    f = Y(s(1),1) - yb %Select the solution y1 in point b and compare with boundary value
return ;

% Define ODE y''= 6*t as a 2-D first order ODE; 
function   dy = def_ODE(t,y)
	 dy = zeros(2,1);    % a column vector
    dy(1) = y(2);
    dy(2) = 6*t;
return;

