Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Using the ODE solver in a FOR loop
Replies: 11   Last Post: Jul 18, 2013 3:44 AM

 Messages: [ Previous | Next ]
 Marc Posts: 108 Registered: 7/2/10
Re: Using the ODE solver in a FOR loop
Posted: Jul 16, 2013 1:09 AM

"Meiyour" wrote in message <ks1376\$ot5\$1@newscl01ah.mathworks.com>...
> Actually, i am trying to solve 4 coupled partial differential equations by the method of lines. I have discretized the space derivative, leaving me with 4 ODEs to solve.
>
> However, i am having problems defining the four ODEs within the same for loop.
> The ODE15s loops through the time elements defined. I want to incorporate a for loop which makes the code iterate through the discretized space elements too.
>
> Basically, i need to use the method of lines for four coupled partial differential equations.
>
> Hope i'm making a bit of sense. Would really appreciate your help.
>
> "Torsten" wrote in message <ks0uf0\$ba9\$1@newscl01ah.mathworks.com>...

> > "Meiyour" wrote in message <ks0rsi\$3k3\$1@newscl01ah.mathworks.com>...
> > > Hi. I need some help with the ODE15 solver.
> > >
> > > I am trying to use the solver four coupled partial differential equations, using the method of lines. However, i need to include the solver in a for loop, but every attemp i've made so far has proved abortive.
> > >
> > >
> > > For i=1:n
> > > u1( t(i), y1(i) ) = ode15(..........);
> > > u2( t(i), y2(i) ) = ode15(...........);
> > > end
> > >
> > > Ant help would be greatly appreciated.

> >
> > What are you trying to do in the above loop ?
> >
> > Best wishes

See Shampine, et al... for Matlab AND MOL. If you set up your function correctly, there should be no need to use a for loop. By setting the time interval, ODE15s is smart enough to find the t and y answers for that interval. If for some reason you think ode15s runs into some issue within that time interval, using a for loop to break up the time span may be appropriate.

Albeit, I have rarely seen this to be the case.

Otherwise, you will need to provide a bit more detail regarding your system and any code that you have attempted for us to be more helpful

Date Subject Author
7/15/13 Meiyour
7/15/13 Torsten
7/15/13 Meiyour
7/16/13 Marc
7/17/13 Meiyour
7/17/13 Torsten
7/17/13 Torsten
7/17/13 Meiyour
7/17/13 Marc
7/18/13 Torsten
7/18/13 Meiyour
7/16/13 Torsten