MATLAB: I want to solve some coupled differential equations using ode45, but here I have to pass some constants in that function as well. How will the code be written.

ode45retag

I want to solve some coupled differential equations using ode45, but here I have to pass some constants in that function as well. How will the code be written.

Best Answer

function dy=yourfunction(t,y,k,g) % k, g are your constants
%your code
To call ode45
[t,y]=ode45(@(t,y) yourfunction(t,y,k,g),tspan,y0)