Call Scripts during Simulink Simulation

94 次查看(过去 30 天)
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

回答(1 个)

Arthi Sathyamurthi
Arthi Sathyamurthi 2021-5-27
There are few possible ways to your question,
  1. 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.
  2. 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.
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.

类别

Help CenterFile Exchange 中查找有关 Model, Block, and Port Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by