When I simulate physical models I often use state space or transfer function matrecies. I like to use this library: https://octave.sourceforge.io/control/overview.html
Very powerful and well updated.
But the problem with physical models is that I cannot set some limits for how much input I can have and the displacement and velocity of the model.
So there are something called discontinuous functions. Simulink has it. Xcos has it and all the other graphical simulation tools.
For example in Simulink. http://x-engineer.org/wp-content/uploads/2017/02/Simulink-model-Discontinuities-Library-blocks.jpg
And the results: http://x-engineer.org/wp-content/uploads/2017/02/Simulink-model-plot-Discontinuities-Library-blocks.png
I'm sorry, I cannot upload pictures here because my webbrowser don't work 100%. It's some small problem with it. Haven't found the solution yet.
So..my question is: Can I create some discontinuous functions with MATLAB/Octave Control packages only? Or do I need to create a for loop or something like that to build my own simulation tool?
How have you solve this kind of problems?