I am trying to implement model predictive control for a non-linear problem, so that I need at least a 4th order solver to prevent divergence (note: no access to the toolbox). For this reason, I thought that using Simulink may be a good option, as it would save me time with the modelling. I was thinking about writing a S-function (Matlab within Simulink) to do this.
As part of the control, I need to find an optimal control force at each time step. This is estimated using a forecast of the excitation force (noise), spanning multiple time steps. Now, this is a big problem, as I do not know how to input this to the S-function.
Note that the excitation force is pregenerated as a vector in Matlab, and then input to the Simulink model through a simin block. So, in theory I would be able to access that data within Simulink, even though I do not know how.
Other inputs to the S-function are the current state and excitation force, but those are not an issue.
Is it possible to use (known) values of the excitation force belonging to a number of future time steps as an input to the S-function?
As an alternative, I am considering using a 4th-order Kutta solver in Matlab.
Thank you for the help!