Initial Guess for Bvp4c

조회 수: 21(최근 30일)
Joao Graca
Joao Graca 2014년 7월 16일
편집: Mark Brandon 2018년 12월 22일
I´m trying to solve a BVP, but i don´t know how to use an array of points as an initial guess. Let me explain: I have 4 1st order diff equation. If i use something like
init = bvpint([0 1],[0 0 0 0])
Matlab acepts, but of course do not converse. But i have 2 vectors, one for the mesh (800x1) and one for the initial guess (800x4). Let me call the mesh X, and the initial guess V. If i try
init = bvpint(X,[0 0 0 0])
it´s ok. But if i try
init = bvpint(X,V)
I already tried a lot of combinations, but till now i have been unable to load an 800x4 vector as my initial guess. Can somebody helps me???


Mark Brandon
Mark Brandon 2018년 12월 22일
편집: Mark Brandon 2018년 12월 22일
This is an old question (2014), but it represents an issue that probably continues to puzzle others (including me today).
The documentation is missing an important clue, in that bvp functions need to be able to remeshing the independent variable x. Thus, one cannot use indexing to relate x to the deriative of the dependent variable, (y, dy, d2y, etc.). This rule holds for the initial guess, and for the ode function (containing the system of differential equations) and the residual function (containing the boundary conditions) as well.
That said, one can use anonymous functions to allow for general relationships between x and the y derivatives (see the bvpinit documentation for details). Let me illustrate with an example:
Instead of:
init = bvpint(X,V),
%row vector xV0, and matrix V0 with column vectors for each element of xV0
init = bvpint(X, @(x) interp1(xV0, V0, x))
@(x) indicates that this is anonymous function. interp1 will provide interpolates for the column vector of derivatives at the specified x.
Similar arrangements are needed for handling calculations involving x in the ode and and residual functions.

Community Treasure Hunt

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

Start Hunting!

Translated by