The Math Forum

Search All of the Math Forum:

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

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

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

Topic: How do I pass a value to a function called by ode45?
Replies: 5   Last Post: Feb 7, 2013 10:42 PM

Advanced Search

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

Posts: 323
Registered: 2/24/09
Re: How do I pass a value to a function called by ode45?
Posted: Feb 7, 2013 3:30 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 05.02.13 23:17, Jeff wrote:

> I was able to make my sample work by adding a third parameter to the declaration of f and then using this call:
> [t_steps,s1]=ode45(@(t,y) f(t,y,beta), t_steps, s0, options);
> But I can't say I understand what it's doing. And I note that t and y are not given values anywhere before the @(t,y) part of that command. But the correct values are being passed into the function (at least the first time) and I'm getting the results I expect.

It defines an anonymous function that takes two values, named t and y
inside this function, and then calls f(t,y,beta). A very useful idiom.


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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.