Save variables while using ode solver
Show older comments
[t,y]=ode45(@fun,tspan,yo);
function dy=fun(t,y)
dy=zeros(3,1);
constant1 = k1*y(3)
dy(1)= constant1;
dy(2)=f1(y(3),y(2))
dy(3)=f2(y(1),y(2))
end
I want to save the variable, constant1, each time the ode solver calls the function fun.
Is there a way to get the iteration count?
If yes, I can use
save_constant1(iter) = constant1.
Any suggestions?
2 Comments
Steven Lord
on 24 Oct 2019
What do you want to happen if the ODE solver evaluates your function for a particular time step but then rejects that step and evaluates your function at an earlier time (a smaller time step from the previous time?)
Deepa Maheshvare
on 25 Oct 2019
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!