[Math] How to solve an ODE with boundary conditions using Matlab solver

MATLABordinary differential equations

My question is very simple: I want to plot a graphic for the deflection of a beam, with consists of a solution of an ODE using a Matlab solver, such as:

%Call Solver -> Linear

[x y] = ode45(@MyFunctionL,xspan, x0);

x0 = [0 0];

xspan = [0 Lg];

function dy = MyFunctionL(x,y)

global Fg Lg EI;

dy = zeros(2,1);

dy(1) = y(2);

dy(2) = (Fg/EI)*(Lg – x);

return

It works perfectly at first, but in another case in which I have to set a condition such as y´(Lg/2)=0 I am having some trouble.
It should result in a sort of Parabolic y(x) if I could "insert" this boundary condition.

I wish to know if I can do it using a MATLAB solver or only with bvp4c.
(I am interested in doing with a solver because later I have to compare the linear solution with a non linear solution)

Thanks very much!

Best Answer

ode45 is for initial value problems: all conditions occur at the same value of the independent variable $x$. It looks to me like what you want is a boundary value problem, where some conditions are at one endpoint of the interval and others at the other endpoint. That's what bvp4c is for.

Related Question