Modification of variable as a function of time ?

2 visualizaciones (últimos 30 días)
Louis Cod
Louis Cod el 1 de En. de 2020
Respondida: Amish el 13 de Feb. de 2025
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.

Respuestas (1)

Amish
Amish el 13 de Feb. de 2025
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!

Categorías

Más información sobre Modeling en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by