Problem with too many inputs into bvp5c

Hello, I want to test whether bvp4c, bvp5c and bvp6c solvers produce the same solution. The problem I face is that bvp4c and bvp6c allow my ode and bc functions to have additional inputs. Namely, these solvers have the following syntax: function sol = bvp4c(ode, bc, solinit, options, varargin) function sol = bvp6c(ode, bc, solinit, options, varargin) The solver bvp5c however, does not allow for varargin: function sol = bvp5c(ode, bc, solinit, options)
So, does anyone know how to go about this issue? Is there a way to manually edit bvp5c to allow for additional inputs?
Thanks, Artem.

 Accepted Answer

Jan
Jan on 9 Nov 2017
Edited: Jan on 9 Nov 2017
You should not use additional inputs at all, even some integrators still support this ancient method. See http://www.mathworks.com/matlabcentral/answers/1971: Use anonymous functions to provide parameters. This is explained in the documentation also: https://www.mathworks.com/help/matlab/ref/bvp5c.html:
Parameterizing Functions explains how to provide additional
parameters to the function odefun, ...

2 Comments

Thanks for the fast reaction, Jan, but I guess this is beyond my programming skills. This is my bvp call:
Solution = bvp4c(@odefun,@bc,Solution_guess,OPTIONS,par);
This is my ode function with endogenous parameters end_par and exogenous parameters par that I need to get around:
function xdot=odefun(t,x,end_par,par)
And this is my boundary condition:
function lhs=bc(x0,xt,end_par,par)
Now, at which place do I need to change smth? I see that I need to use @ handles, but the examples in the documentation are not matching my problem (more than one x as function argument).
OK, seems I figured it out. Just needed to change the bvp call:
Solution = bvp4c(@(t,x,end_par) odefun(t,x,end_par,par), @(x0,xt,end_par) bc(x0,xt,end_par,par), Solution_guess, OPTIONS);

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!