Share a state variable between 2 masked S-Function
古いコメントを表示
We are having some issues when trying to share a state variable between 2 masked S-Function. In the picture below, as you can see there is the same S-Function called 2 times behind a mask. In this example, the S-Function is a SR Flip Flop:
The green block is supposed to set the State variable (passed as a Mask Parameter) of the Flip Flop to a specific value (true or false) such that the orange block can use it during the execution.

Since the 2 inputs of the orange block are ‘false’ the output of the block should be the previous state. In this case, if the state is shared between the 2 subsystems, the 2 signals inputs to the scope should be the same signal. However, the orange block and the green block never share the same state even if the 2 mask parameters point to the same data dictionary variable (Below the Mask we have the state name passed to the Mask). In the picture below you will find both the scope representing the 2 signals.

We have properly passed the state to the S-function as a parameter inside the mask and the state is correctly updated at each step inside the S function, the issue is that the data dictionary variable is never updated by the S-function, only the variable inside the simstruct gets updated during the execution of the S-function.

採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Block and Blockset Authoring についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!