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: Can not pass variable to ode45
Replies: 1   Last Post: Jun 20, 2013 2:29 AM

Advanced Search

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

Posts: 1,472
Registered: 11/8/10
Re: Can not pass variable to ode45
Posted: Jun 20, 2013 2:29 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Sandip" wrote in message <kpt6ra$4ao$1@newscl01ah.mathworks.com>...
> Hi:
> Please suggest a way... I have a command as below to solve the ode by ode45 and I need to pass three variables.
> [x,y]=ode45(@fnode,xspan,y0,c1,c2,c3);
>
> I have defined the function in .m file as
> function yprime = fnode(x,y,c1,c2,c3)
>
> However, I can not read in the c3 in the function (ode) file. c1 & c2 are coming alright.
>
> Please help.


But I already gave you the solution ...
Call ode45 as
[x,y]=ode45(@(x,y)fnode(x,y,c1,c2,c3),xspan,y0)
and define the function in an .m file as
function yprime = fnode(x,y,c1,c2,c3)

Best wishes
Torsten.



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.