How to initialise Goto variables used in enabled subsystems

7 Ansichten (letzte 30 Tage)
Daniel
Daniel am 29 Nov. 2022
Kommentiert: Djordje am 13 Aug. 2024
How can I initialise Goto variables in an enabled or switch case action subsystem?
I use the Goto blocks to reinitialize the integration variable when one subsystem is enabled, as described here: Building a Clutch Lock-Up Model
Now I can't find a clean way to initialize the goto variables when the model is started. As there is no previously active subsystem, no value can be passed to initialize the variable.

Akzeptierte Antwort

Jim Riggs
Jim Riggs am 29 Nov. 2022
You should not need to "initialize" the Goto variables. The "Goto / from" blocks are simply a way to connect a signal without showing the connecting line. The Goto block gets its value from the signal line that is the input to the block.
  4 Kommentare
Daniel
Daniel am 1 Dez. 2022
First of all, thank you very much for your answer and the work you put into it.
My model is a periodical one, that has three operation states where one of them is active at a time. Sorry that I didn't describe that sufficiently, but your assumption is still leading to my key problem.
My problem is based on my use of the 'Goto' and 'From' blocks. In each subsystem, a 'Goto' block is connected to the 'State' port of the integrator. This 'Goto' block is transmitting the last state of this integrator block to the one in the next subsystem active. In this new subsystem the 'From' block is providing the initialization value for the integrator block of this new subsystem. This procedure is done every time the active subsystem changes to pass on the integration value. Now the problem arised, that I had to provide a general initialization for the integration value when the simulation starts. I couldn't easily provide a initialization value, as this would have been used every time the subsystem is reactivated. I hope that is a better description of my problem.
However, I thought I am just missing the setting for this initialization somewhere. Till now I was using an external signal to solve my problem, but my implementation of this solution was problematic in some ways.
So now I'm using parts of your answer as a solution to my problem that work much better for me.
Thank you very much and sorry again for the badly described problem.
Djordje
Djordje am 13 Aug. 2024
Hello @Daniel,
Did you find the solution that fits better to your issue?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Conditionally Executed Subsystems and Models finden Sie in Help Center und File Exchange

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by