How to modify output of an ode?

2 views (last 30 days)
Simon
Simon on 17 Sep 2015
Answered: Steven Lord on 17 Sep 2015
Hello,
my ODE looks like:
function [sol] = ode(t,z)
A = z(1);
B = z(2);
C = z(3);
if t = 0.01
B=2;
end
dAdz = B;
....
I like to modify my solution z(1) on the time stept t = 0.01. However, in the next step is A = 0 ( A = z(1) in next step) like the hole time before.
Do you know how I can manipulate the solution of the step t+dt?
Thank you

Accepted Answer

Steven Lord
Steven Lord on 17 Sep 2015
Solve your ODE up to time t = 0.01. Use the solution at time t = 0.01 to generate a new initial vector for the system of ODEs. Call the ODE solver again with the new initial vector to calculate the solution on the interval from t = 0.01 to your new endpoint.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!