MATLAB: ODE45() & Importing Variables in to Functions Inside It

functioninputodeode45variable

I am using ode45 on my function; "derivs_func_5". It provides derivatives for ode45.
That function needs to have a value imported in to it "r" before ode45 hits it to provide those derivatives.
This is what the working code looks like:
[t,coords] = ode45(@derivs_func_5,[t_init t_fin],[x_init y_init v_x_init
v_y_init],ode_options);
This is what I am trying to do but matlab is not letting me do:
r=5;
[t,coords] = ode45(@derivs_func_5(r),[t_init t_fin],[x_init y_init v_x_init
v_y_init],ode_options);
Is there any way to set input variables for a function what appears inside ode45 function?
thanks

Best Answer

[t,coords] = ode45(@(t,y) derivs_func_5(t,y,r), [t_init t_fin],[x_init y_init v_x_init v_y_init], ode_options);
Related Question