SimEvent MDES access to external Data

조회 수: 4 (최근 30일)
Marc Elpel
Marc Elpel 2021년 5월 15일
답변: Akanksha 2025년 8월 28일
I have a SimEvent MDES model that performs custom scheduling based on an external dataset (matrix data imported from Excel). Data has been imported into the Workspace, and can be viewed in the Model Explorer / Model Workspace.
What I am trying to do is use this in the MDES... for example:
entity.AttributeX = MyData(5,9);
MyData is not local to the MDES so it is not recognized, and so far I've found no way to make it vissible there for use.
How can I get the Workspace data into the MDES for use?

답변 (1개)

Akanksha
Akanksha 2025년 8월 28일
The MDES block cannot directly access variables like MyDatafrom the base or model workspace, so referencing MyData(5,9) inside the MDES will not work. Instead, you need to pass your data as a parameter to the MDES block to use it in your code.
  1. Add a Parameter to the MDES Block: In the MDES editor, go to the Parameters tab and add a new parameter named “MyData”.
  2. Set the Parameter Value in Simulink: In your Simulink model, click on the MDES block, open its parameters dialog, and set “MyData” to the name of your imported matrix (for example, MyData).
  3. Use the Parameter in Your MDES Code: In your MDES code, access the data using “self.MyData”. For example:
entity.AttributeX = self.MyData(5,9);
This way, your external data will be available inside the MDES block for your scheduling logic.
Following is the official documentation link for further understanding :
Hope this helps!

카테고리

Help CenterFile Exchange에서 SimEvents에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by