BVP: Example 2 - Code

Required for all ODE is the expression of the problem in state space which is

Graphical Solution
MATLAB Code
function bvpexample_2
% BVP  _ Example 2
% P.Venkataraman

set(gcf,'Menubar','none','Name','BVP Example 2 - Laminar Flow over a Flat Plate', ...
    'NumberTitle','off','Position',[10,350,350,300], ...
    'Color',[0.4 0.4 0.7]);

solinit = bvpinit(linspace(0,7,100),@mat4init);
% initialize the solution

sol = bvp4c(@blassius,@mat4bc,solinit);
% call the BVP solver

% calculate the bvp solution at 20 points
xint = linspace(0,7);
Sxint = bvpval(sol,xint);  % helper function that calculates the solution

% actual solution
tint = [0 7];
zinit = [0 0 0.33206];
[tt zz] = ode45(@blassius,tint,zinit);
 

% plots
plot(Sxint(2,:), xint,'r','LineWidth',1)
hold on
plot(zz(:,2),tt,'k:','LineWidth',2);
xlabel('u/U_{\infty}', ...
    'FontWeight','b','Color','w', ...
    'VerticalAlignment','middle');
ylabel('x', ...
    'FontWeight','b','Color','w', ...
    'VerticalAlignment','bottom');
legend('u/U_{\infty} - bvp', 'u/U_{\infty}- actual')
title('\bf\itBVP Example 2 - Blassius Equation','Color','w', ...
    'VerticalAlignment','bottom')
set(gca,'Color','w')
grid
hold off

%  Assemble the other functions here
function dydx = blassius(x,y)
% this is the differential equation in state space
dydx = [   y(2)
            y(3)
            -0.5*y(1)*y(3)];
 

function res = mat4bc(ya,yb)
% this is where the boundary conditions are defined
% ya is the intial vector
% yb is the final vector
res = [  ya(1)
         ya(2)
         yb(2)-1];

function yinit = mat4init(x)
% set up intial guess - a staraight line
yinit = [  x
        0
        0];