How to execute a k-step predictor within a real-time Simulink model
Hi,
I’m trying to implement a k-step predictor within a real-time Simulink model. For each time step in the real-time simulation, values will be used as initial conditions in a predictor model (nonlinear Simulink model, quite extensive) and marched forward multiple time steps, and then the final predicted value is returned and carried on within the real-time simulation.
The primary concern is that the predictor model contain integrators, which cannot be run repeatedly within each real-time step. I have looked into For Loop blocks, but then I would have to write my own integrators.
Alternatively, I have looked into placing the predictor in a separate "offline model" running in normal mode, where it is called at every real-time step. The issue I ran into with this is the amount of overhead I have to load in when running the extensive predictor model, and thus it won’t be completed between each real-time step.
I understand that this could be done a lot easier if the predictor model is in the form of matlab script rather than a Simulink model. However, the predictor model is quite complex, and it would be highly prefered to not needing to re-write it into script form.
I have been stuck on trying different workarounds, but without much luck. I would greatly appreciate if anyone can shed some light on directions I can take.
Thanks in advance,
TimHi,
I’m trying to implement a k-step predictor within a real-time Simulink model. For each time step in the real-time simulation, values will be used as initial conditions in a predictor model (nonlinear Simulink model, quite extensive) and marched forward multiple time steps, and then the final predicted value is returned and carried on within the real-time simulation.
The primary concern is that the predictor model contain integrators, which cannot be run repeatedly within each real-time step. I have looked into For Loop blocks, but then I would have to write my own integrators.
Alternatively, I have looked into placing the predictor in a separate "offline model" running in normal mode, where it is called at every real-time step. The issue I ran into with this is the amount of overhead I have to load in when running the extensive predictor model, and thus it won’t be completed between each real-time step.
I understand that this could be done a lot easier if the predictor model is in the form of matlab script rather than a Simulink model. However, the predictor model is quite complex, and it would be highly prefered to not needing to re-write it into script form.
I have been stuck on trying different workarounds, but without much luck. I would greatly appreciate if anyone can shed some light on directions I can take.
Thanks in advance,
Tim Hi,
I’m trying to implement a k-step predictor within a real-time Simulink model. For each time step in the real-time simulation, values will be used as initial conditions in a predictor model (nonlinear Simulink model, quite extensive) and marched forward multiple time steps, and then the final predicted value is returned and carried on within the real-time simulation.
The primary concern is that the predictor model contain integrators, which cannot be run repeatedly within each real-time step. I have looked into For Loop blocks, but then I would have to write my own integrators.
Alternatively, I have looked into placing the predictor in a separate "offline model" running in normal mode, where it is called at every real-time step. The issue I ran into with this is the amount of overhead I have to load in when running the extensive predictor model, and thus it won’t be completed between each real-time step.
I understand that this could be done a lot easier if the predictor model is in the form of matlab script rather than a Simulink model. However, the predictor model is quite complex, and it would be highly prefered to not needing to re-write it into script form.
I have been stuck on trying different workarounds, but without much luck. I would greatly appreciate if anyone can shed some light on directions I can take.
Thanks in advance,
Tim predictor, real-time, integrator MATLAB Answers — New Questions