Call Scripts during Simulink Simulation

조회 수: 152 (최근 30일)
Marcus Heßeling
Marcus Heßeling 2021년 5월 17일
답변: Arthi Sathyamurthi 2021년 5월 27일
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