I have a class function that uses ODE45 to solve some equations. I have another, private class function that represents the odefunction that ODE45 needs to solve. However, I can't figure out how to pass a handle of the class's ode function to ODE45. Here is the sample code:
class ODESolver < handle
methods (Access = public)
function obj = RunODE(obj, t, y0)
[~, Z] = ode45(@ODEFunction, t, y0);
end
end
methods (Access = private)
function dy = ODEFunction(t,y)
% Calculate dy here.
end
end
end
When I run this, i get an error saying:
Undefined function 'ODEFunction' for input arguments of type 'double'.
If I move ODEFunction outside of the class and put it in its own *.m file, the code runs fine. I've also tried using "@obj.ODEFunction" in the ode45 call, but then it says:
Too many input arguments.
What's the best way to keep ODEFunction inside of my class and still be able to pass it's handle to ode45?