Modification of variable as a function of time ?

4 ビュー (過去 30 日間)
Louis Cod
Louis Cod 2020 年 1 月 1 日
回答済み: Amish 2025 年 2 月 13 日 4:07
Hello,
I am a beginner in simulink and I would like to know how it is possible to modify the value of a variable every second in the following way:
- If variable 1 is 0, do nothing
- If variable 1 is worth 1, increment variable 2 by 300 every second
- If variable 1 is worth 2, decrease variable 2 by 500 every second
Thank you in advance for your help.

回答 (1 件)

Amish
Amish 2025 年 2 月 13 日 4:07
Hi Louis,
To achieve this in Simulink, you can use a combination of blocks to create a simple model that modifies the value of a variable every second based on the conditions you specified. You will need to have the following blocks in the model:
Constant Block, Integrator Block, Clock Block, Relational Operator Blocks, Switch Blocks, Gain Blocks and a Sum Block.
The connections could be made as follows:
  • Constant block to the input of the Relational Operator blocks.
  • Outputs of the Relational Operator blocks to the control inputs of the Switch blocks.
  • Clock block to the Integrator block to ensure updates occur every second.
  • Outputs of the Gain blocks to the Sum block.
  • Sum block to the Integrator block.
  • Output of the Integrator block to the Scope block for visualization.
You can then set the simulation time, simulate and observe the results.
Additionally, you can use the following documentation for more information on the blocks used:
Hope this helps!

カテゴリ

Help Center および File ExchangeGeneral Applications についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by