Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Help with ODE Problem
Replies: 7   Last Post: Jul 23, 2013 12:35 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Marc

Posts: 108
Registered: 7/2/10
Re: Help with ODE Problem
Posted: Jul 23, 2013 12:35 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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:
> > http://www.mathworks.com/matlabcentral/answers/1971
> >
> > 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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.