Modification of variable as a function of time ?

조회 수: 5 (최근 30일)
Louis Cod
Louis Cod 2020년 1월 1일
답변: Amish 2025년 2월 13일
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일
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 CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by