The Parameter of ODE is not Updated When the EventCallback Function is Called
Show older comments
I was simulating ODEs which incorporate additional parameter (ydot = f(t,y,P)).
There is an event occurs in the simulation process and the event is processed with odeEvent function.
The eventCallback function is illustrated as follows:
function [stop,Ye,Pout] = impactEventCallback(te,ye,ie,Pin)
% ... parameter updating calculation
fprintf("parameter befor updating : %.5f After updating : %.5f \n",Pin.v,Pout.v); % output updating result
end
The simulation result is demonstrated as follows:
parameter befor updating : 0.10000 After updating : 0.37232
parameter befor updating : 0.10000 After updating : 0.08382
parameter befor updating : 0.10000 After updating : 0.06401
...
It seems that every time the impactEventCallback function is called, the parameter before updating (Pin) is not changed.
I suspect that the updated parameter Pout is not used by the governing equations ydot = f(t,y,P).
The expected result should be that the next time the value of Pin is the last time value of Pout.
Can anyone give some advices about how to fix this issue ?
Answers (1)
Chuguang Pan
on 28 Dec 2024
Moved: Walter Roberson
on 28 Dec 2024
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!