How to initialise Goto variables used in enabled subsystems

조회 수: 7 (최근 30일)
Daniel
Daniel 2022년 11월 29일
댓글: Djordje 2024년 8월 13일
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.

채택된 답변

Jim Riggs
Jim Riggs 2022년 11월 29일
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
Daniel
Daniel 2022년 12월 1일
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 2024년 8월 13일
Hello @Daniel,
Did you find the solution that fits better to your issue?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Conditionally Executed Subsystems and Models에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by