I understand that the issue is with solving a system of differential equations within stateflow. One workaround might be to create a MATLAB function in a separate '.m' file containing the logic for solving the differential equations and call the function within the Stateflow by declaring it using 'code.extrinsic()'. During simulation, the code generator produces the code for the call to an extrinsic function but does not produce the function’s internal code. You could look at the following MATLAB code & Stateflow chart.
function [t,y] = differentialEquation(tspan)
[t,y] = ode45(@(t,y) 2*t, tspan, y0);
This function is called within the state 'ON' in the following Stateflow chart by declaring it as 'coder.extrinsic()'.
You could refer this for more information regarding “coder.extrinsic()”.
Hope this helps!