From: Mirko on 7 Jun 2010 07:51 Hi to all, I have this problem. I have something like this: [time,states]=ode113(@rates,[0 t_final,[initial_conditions]]); in rates function i need the current time value at which ode is evaluating the solution because I need it to calculate a value in the rates function. Is it possible? Is there any way to get it?
From: Mirko on 7 Jun 2010 08:00 "Mirko " <vgsangiuliano(a)gmail.com> wrote in message <huimf8$m4v$1(a)fred.mathworks.com>... > Hi to all, > I have this problem. > I have something like this: > > [time,states]=ode113(@rates,[0 t_final,[initial_conditions]]); > > in rates function i need the current time value at which ode is evaluating the solution because I need it to calculate a value in the rates function. > Is it possible? Is there any way to get it? Sorry I will try to be more precise. I think i can use the t value in my rates function because my rates function is something like derivatives=rates(t,states) My problem is that I call other functions inside rates and I don't know how to pass t value from rates to the other funtion. Thanks
From: Steven Lord on 7 Jun 2010 09:16 "Mirko " <vgsangiuliano(a)gmail.com> wrote in message news:huin0l$sal$1(a)fred.mathworks.com... > "Mirko " <vgsangiuliano(a)gmail.com> wrote in message > <huimf8$m4v$1(a)fred.mathworks.com>... >> Hi to all, >> I have this problem. >> I have something like this: >> >> [time,states]=ode113(@rates,[0 t_final,[initial_conditions]]); You've got a closing square bracket in the wrong place. The time span [0 t_final] is a separate input argument from the initial condition vector; move the third ] to just after t_final. >> in rates function i need the current time value at which ode is >> evaluating the solution because I need it to calculate a value in the >> rates function. >> Is it possible? Is there any way to get it? > > Sorry I will try to be more precise. > I think i can use the t value in my rates function because my rates > function is something like derivatives=rates(t,states) That is correct; as stated in the help text and documentation, ODE113 requires your ODE function (rates in this case) to accept input arguments t and y and return y' = f(t, y). > My problem is that I call other functions inside rates and I don't know > how to pass t value from rates to the other funtion. Exactly the same way you'd pass a value to any other function. function yprime = rates(t, y) yprime = zeros(size(y)); yprime(1) = myotherfunction(t, y); -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
Pages: 1 Prev: Fit throws an Error ('pfull') Next: 3-dimensionnal array |