Can i restart s-function while on-simulation?

4 ビュー (過去 30 日間)
종한 김
종한 김 2022 年 6 月 15 日
回答済み: Atharva 2023 年 9 月 4 日
Hi. I am simulating two s-functions in one simulink model.
In order to make one s-function awake->dead->awake while running, i want to off and on one s-function.
Is there any way to do this?
  1 件のコメント
종한 김
종한 김 2022 年 6 月 15 日
in specific, i want to make one s-function's global variable to be initialized.

サインインしてコメントする。

回答 (1 件)

Atharva
Atharva 2023 年 9 月 4 日
Hey 종한 김,
I understand that you are trying to restart S-function while-on simulation.
In Simulink, you can control the execution of S-functions, including turning them on and off, by using signal routing and conditional statements. To make one S-function go from an "awake" state to a "dead" state and back to an "awake" state during simulation, you can follow these general steps:
  1. Conditional Execution: You'll need to implement conditional execution in your S-function to control its behavior. You can use an input signal or a parameter to toggle between "awake" and "dead" states.
  2. Conditional Subsystem: Wrap your S-function with a subsystem in Simulink. Use a condition (e.g., an If block) in the subsystem to control whether the S-function runs or not based on the input signal or parameter. When the condition is met, the S-function will be "awake," and when it's not met, it will be in the "dead" state.
  3. Signal Routing: To toggle between the "awake" and "dead" states dynamically during simulation, you can use signal routing blocks like Switch, Multiport Switch, or a MATLAB Function block to control the input to the subsystem containing your S-function. These blocks can be configured to switch between different signals or values based on a condition.
Remember to adjust the sample time and rate of execution of your S-functions to ensure they operate correctly in your simulation.
These steps provide a high-level overview of how to control the execution of S-functions in Simulink based on a condition. You can tailor the details to match your specific needs and the complexity of your S-functions.
I hope this helps!

カテゴリ

Help Center および File ExchangeBlock and Blockset Authoring についてさらに検索

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by