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: Help with ODE Problem
Replies: 7   Last Post: Jul 23, 2013 12:35 AM

 Messages: [ Previous | Next ]
 Marc Posts: 108 Registered: 7/2/10
Re: Help with ODE Problem
Posted: Jul 23, 2013 12:35 AM

"Torsten" wrote in message <ksil62\$k9p\$1@newscl01ah.mathworks.com>...
> "Jan Simon" wrote in message <kshjrc\$b7g\$1@newscl01ah.mathworks.com>...
> > Dear Marc,
> >

> > > > [T,Y]=ode15i(@(t,y) Differential_Equation_Solver(t,y,K,M,C,P),tspan,y0,yp0);
> > > >
> > > > function dydt=Differential_Equation_Solver(t,y,K,M,C,P)
> > > > dydt(1) = y(2);
> > > > dydt(2) = M\(P-C*y(2)-K*y(1));
> > > > end
> > > >

> >
> > > You can not pass the K,M,C,P variables into the solver. See "nested functions" or the documentation on "passing other variables into functions" with the Matlab ODE solvers.
> >
> > It is valid and recommended to pass constants by using anonymous functions, see:
> >
> > The problem is the yp0. This is another method to pass constants to the function to be integrated. But the function Differential_Equation_Solver does not accept further parameters in the inputs. So omitting yp0 as input to ODE45 should solve the problem, as mentioned above.
> >
> > Kind regards, Jan

>
> Two further errors in the code:
> 1. The OP tries to solve 152 ODEs, not only 2 as implied by the function Differential_Equation_Solver.
> 2. For ODE15i, you will have to supply residuals, not time derivatives.
>
> Best wishes
> Torsten.

Yeah, this threw me off. I missed the anonymous function call.

Date Subject Author
7/12/13 Lauara
7/15/13 Jan Simon
7/15/13 Lauara
7/15/13 Marc
7/21/13 Jan Simon
7/22/13 Torsten
7/23/13 Marc
7/16/13 Torsten