Initial Guess for Bvp4c

12 次查看(过去 30 天)
Joao Graca
Joao Graca 2014-7-16
编辑: Mark Brandon 2018-12-22
Hello!
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)
it gives an error: "THE GUESS FOR THE SOLUTION MUST RETURN A VECTOR".
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???
Thx!

回答(1 个)

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),
try:
%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.

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by