- You can call a MATLAB script from Simulink by using any of the callbacks as per your workflow and then use it in the program. The callbacks function allows you to add callbacks at different part of the simulation. To know more about modelling callback parameters, refer to the MathWorks documentation here.
- Another option to call a Matlab script is to use the MATLAB function block in Simulink. To look for an example on how to use MATLAB function block click here.
Call Scripts during Simulink Simulation
95 views (last 30 days)
Show older comments
Hey Guys
I have a problem with a Simulink modell. In General my work is this:
I have multiple Bodyparts and their positions are saved in the Workspace. After the Simulation i run a Script that checks the Data that was saved in the workspace for Collisions. Now i want to implement this script within the Simulink Model, for example with function callbacks of the script. The goal is that at every 10% of my simulation time the Script will run and check for collision. If no collisions are found it continues and then stops when the first collision occured:
10% = no collision, 20% = no collision, 30% = collision => stop simulink modell an give a warning/info
Thanks for your help
0 Comments
Answers (1)
Arthi Sathyamurthi
on 27 May 2021
There are few possible ways to your question,
Further to call the script during specific simulation time, you can use the clock block to get the simulation time (Calculate the percent of the simulation time by using the total simulation time and the value from the clock block) and have any of the control-flow logic block to check your condition.
0 Comments
See Also
Categories
Find more on Model, Block, and Port Callbacks 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!