Matlab ode45. How to change a parameter inside it while calling it?
You want make F an argument of your derivative function and pass the right anonymous function to ode45: [t,N] = ode45(@(t,y) rateEquations(t,y,F), timeSpan, initialConditions)
You want make F an argument of your derivative function and pass the right anonymous function to ode45: [t,N] = ode45(@(t,y) rateEquations(t,y,F), timeSpan, initialConditions)
Inserting large discontinuities in your ODE in the way you suggest (and the way illustrated by @macduff) can lead to less precision and longer computation times (especially with ode45 – ode15s might be a better option or at least make sure that your absolute and relative tolerances are suitable). You’ve effectively produced a very stiff … Read more
One option is to use the APIs that commercial solvers like CPLEX and Gurobi provide for C/C++. Essentially, these APIs let you build the model in logical chunks (objective function, constraints, etc.). The APIs do the work of translating the logic of the model to the matrices and vectors that the solver actually needs in … Read more