Using BVP solver to solve 4th order non-linear ODE

Hi, I am trying to solve an ODE of the following structure
-K1 y''''+K2(y) y''+ A(y) y'^2=0 with the boundary conditions y(0)=y(5)=0, y'(0)=y'(5)=0.1
This is a highly nonlinear ODE with fourth order gradients. I tried to structure it in the way that is required as an input to bvp4c, defining y'(1)=y(2); y'(2)=y(3); y'(3)=y(4); y'(4)= (K2(y(1))*y(2)+A(y(1))*y(1)^2)
and the boundary conditions as y1(0); y1(5); y2(0)-0.1; y2(5)-0.1
But this is not working since apparently y(3) is not accepted by bvp4c.
Please let me know how to go about it and if there is another way to solve this in Matlab using inbuilt routines.
Thank you

Respuestas (1)

Torsten
Torsten el 23 de En. de 2015

0 votos

According to your differential equation,
y4'=(K2(y1)*y3+A(y1)*(y2)^2)/K1;
Best wishes
Torsten.

6 comentarios

Hi, I am sorry for the typo here. I was indeed using the same expression as you wrote for y4'
I am probably making a mistake in defining the function. The function file is attached.
I am not sure if instead of having just two arguments (x,y) in dydx=fourode(x,y) I should have 4. The reason I did this is because there is only one dependent variable y and one independent variable x.
The error that I get on compiling is
Attempted to access y(3); index out of bounds because numel(y)=2.
Error in fourode (line 6) dydx=[y(2); y(3); y(4); (gam*A.*(y(2).^2)+Kt*y(3))/kap]
I am sorry if I am being too detailed and thanks in advance for the help. --P.
Torsten
Torsten el 26 de En. de 2015
From the error message you supply, I would conclude that you only supply a vector with two components as initial condition for y.
Could you include the call to bvp4c to check this ?
Best wishes
Torsten.
I corrected that and the function specifying the boundary condition is as follows
function res=fourbc(y1a,y1b,y2a,y2b) res=[y1a(1);y1b(1); y2a(2)-0.1;y2b(2)-0.1]; end
I am now calling bvp4c as following
solinit=bvpinit(linspace(0,5,20),[0 0 0 0]) sol=bvp4c(@fourode,@fourbc,solinit)
But this now gives an error of not enough input arguments in the boundary conditions.
must read
function res=fourbc(ya,yb)
res=[ya(1);yb(1); ya(2)-0.1;yb(2)-0.1];
end
Best wishes
Torsten.
Possibly the last issue with this. I get this error msg now The derivative function ODEFUN should return a column vector of length 4
To resolve this I tried to call bvpinit as solinit=bvpinit(linspace(0,5,20),[0;0;0;0]) so that the initial vector is a column vector but the error msg remains same.
Torsten
Torsten el 2 de Feb. de 2015
In the MATLAB examples, the vector of initial conditions is a row vector, so
solinit=bvpinit(linspace(0,5,20),[0 0 0 0])
should be correct.
I don't know what you return in ODEFUN, but it must be a column vector of length 4.
Best wishes
Torsten.

Iniciar sesión para comentar.

Preguntada:

el 22 de En. de 2015

Comentada:

el 2 de Feb. de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by