Prev: How to read a text (txt) file, modify and save
Next: ginput working, but crosshairs and cursor become invisible while selecting
From: Melanie Roberts on 31 Mar 2010 21:48 Hopefully this is an easy question, but I'm wanting to initialise my bvp4c solver using the output of a different solver, consequently I have a vector rather than an equation I'd like to use with bvpinit - how am I to do this? I've tried with a basic problem but find that if I simply input the vector I end up with my vector repeated as column vectors, so get a 10 x 10 rather than 1 x 10 array. E.g. if xint = linspace(0,5,10) and val = xint.^2 and I form solinit = bvpinit(xint,val) then solinit.y(:,0) returns 0 0.3086 1.2346 2.7778 4.9383 7.7160 11.1111 15.1235 19.7531 25.0000 when I want it to be returning only the 0. Likewise solinit.y(:,5) returns the above rather than just 4.9383. Any ideas how to get this working would be much appreciated - Melanie
From: Ivan Werning on 31 Mar 2010 23:10 "Melanie Roberts" <kthelephant(a)hotmail.com> wrote in message <hp0u0k$kuf$1(a)fred.mathworks.com>... > Hopefully this is an easy question, but I'm wanting to initialise my bvp4c solver using the output of a different solver, consequently I have a vector rather than an equation I'd like to use with bvpinit - how am I to do this? > > I've tried with a basic problem but find that if I simply input the vector I end up with my vector repeated as column vectors, so get a 10 x 10 rather than 1 x 10 array. > > E.g. if > xint = linspace(0,5,10) and val = xint.^2 > and I form > solinit = bvpinit(xint,val) > then > solinit.y(:,0) > returns > 0 > 0.3086 > 1.2346 > 2.7778 > 4.9383 > 7.7160 > 11.1111 > 15.1235 > 19.7531 > 25.0000 > when I want it to be returning only the 0. Likewise solinit.y(:,5) returns the above rather than just 4.9383. > > Any ideas how to get this working would be much appreciated - Melanie What worked for me is to take the solution from another ODE solver (that's what I interpret you want in your first paragraph), say ode45, and use it defined as a structure, i.e. solinit = ode45(@myfun,...) and then feed this structure as the guess. Thus, you do not pass the initial solution as a vector, or constructing a guess from a vector (using bvpinit). Hope this helps. -Ivan
From: Melanie Roberts on 5 Apr 2010 20:23
Hi Ivan, Thanks for your reply. Unfortunately that doesn't appear to be working - I think because the previous solution structure involves parameters, while the current problem does not. Melanie |