How to efficiently translate an s-function for PDE integration from Simulink to an mfile script?

2 views (last 30 days)
Hello Matlab community! I am trying to generalize a Simulink simulation for one robot to multiple robots. The number of robots should be a parameter of the simulation. At every time step the robots interact and after the definition of the commands the states are computed through forces and moments integration. Since the simulated robots can not run in parallel (indeed, they interact), I decided to convert my Simulink simulation to scripts, where now the robot is an object and a 'main' script takes care of the robots generation and state evolution. In Simulink, the integration was made by an S-function and the simulation was running quite fast. On the new mfiles the integration is done by calling ode23. What I observe is that the new simulation with one robot runs 3 times slower, even after increasing the integration step. I guess that Simulink is optimized for running S-functions. Any suggestion to shorten the integration time? Or how to run many instances of the same Simulink simulation that need to interact?

Answers (0)

Categories

Find more on Robotics System Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!