Isra Naz
New member
- Joined
- Aug 27, 2022
- Messages
- 1
- Programming Experience
- 3-5
In the Matlab ODE Solver has a way to terminate integration when an event triggers. It has a function called "Ode45" to solve differential equation using Runge-Kutta method and call an event to terminate the function as follows:
Is there a way to implement this kind of triggering in C#? how can I use Math.Net RungeKutta.FourthOrder() for this?
C#:
%Evaluate system of differential equations.
tspan=[0 t_max]; %Time span of simulation in sec
Opt = odeset('Events', @myEvent);
[t,x]=ode45(@EoM,tspan,x0,Opt); %Run the ODE solver
%% Termination function for ODE.
%Terminate when altitude is less than 0 meaning that the munition impacted
%the ground.
function [value, isterminal, direction] = myEvent(t, y)
%value = (y(11) < 0);
value = y(11);
isterminal = 1; % Stop the integration
direction = -1;
end
Last edited by a moderator: