Info

This question is closed. Reopen it to edit or answer.

How to use level 2 s function block more than once in a model without overwriting values from each block?

1 view (last 30 days)
Hello, I have a simple question. I want to realize a model for a pipe system with numerous level 2 s function blocks which are describing the single pipe sections. Each s function block gets different values for length, diameter, ect. In the s function I can store these values in the Dwork vector as follows:
block.Dwork(1).Name = 'Length';
block.Dwork(1).Dimensions = N;
block.Dwork(1).DatatypeID = 0; % double
block.Dwork(1).Complexity = 'Real'; % real
block.Dwork(1).UsedAsDiscState = true;
L=block.DialogPrm(1).Data;
block.Dwork(1).Data=L;
But if I have more than one Level 2 s functions than I also have block.Dwork(1) - vectors more often in my model. How can I get sure this Dwork vector don't gets overwritten by every single Level 2 s function block? Maybe I can change the expression 'block' in every s function block like: block1.Dwork(1), block2.Dwork(1), block3.Dwork(3) .
Unfortunately, in this case I need different Level 2 s functions for every single block I insert in my Simulink model. Would be great if someone could explain to me how the storage of variables works if there is a Level 2 s function block more than once in a model of Simulink.
Thanks!

Answers (0)

Community Treasure Hunt

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

Start Hunting!