MATLAB Answers


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

Asked by MarkusP
on 24 Feb 2018
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;
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.


Sign in to comment.

0 Answers