Borrar filtros
Borrar filtros

How to stop if else condition after it executes only once.

3 visualizaciones (últimos 30 días)
RUPESH TATTE
RUPESH TATTE el 26 de Jun. de 2021
Editada: Jonas el 27 de Jun. de 2021
I have created a simulink block to execute if else condition. But, I need to stop this condition after it exucute once. How to do it?
  3 comentarios
RUPESH TATTE
RUPESH TATTE el 26 de Jun. de 2021
Editada: RUPESH TATTE el 26 de Jun. de 2021
Below is my if else condition simulink model. In this model, I want output to be zero when voltage is varrying from 0 to 2.2 volt shown in 2nd figure, but it should not be zero when voltage varrying from 2.2 to 0 volt. Means I want this if else condition to be executed only once.
Soniya Jain
Soniya Jain el 27 de Jun. de 2021
I am not sure but you can try to use "persistent" variable in your code, persistent means that the variable will still remember its value the next time the function is called. Refer a MATLAB Answer https://www.mathworks.com/matlabcentral/answers/113017-only-check-if-statement-once-or-disable-code-block-after-1-check

Iniciar sesión para comentar.

Respuestas (1)

Jonas
Jonas el 27 de Jun. de 2021
Editada: Jonas el 27 de Jun. de 2021
Put your blocks inside an enabled subsystem, and use the outputs of your if-else block to disable the subsystem itself.

Categorías

Más información sobre Model, Block, and Port Callbacks en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by