0

The flag of the S-function module is a variable defined in the system. The flag of one S-function affects the flag of another S-function, resulting in a running error. I would like to ask if there is any way to run multiple S-function modules in one MATLAB/Simulink model, as shown in the figure.Multiple S-function modules in a model

I am trying to run a MATLAB/Simulink model which includes multiple S-function modules.

LEON
  • 1
  • 1
  • I don't think your problem is multiple s-functions, but the fact that one changes the other. – Ander Biguri May 10 '23 at 10:03
  • Yes, you are right. Two s-functions in one Simulink model result in some mess. The flag and state are shared. Have you ever tried to use two s-functions in one model? – LEON May 12 '23 at 07:49
  • Due to how complation of S-function works, I believe there is only instance of all static memory for all functions. You can try using a DWORK variable to store your flag (https://www.mathworks.com/help/simulink/sfg/about-dwork-vectors.html) to make it instance-specific. – Evgenii.Balai May 14 '23 at 22:15

0 Answers0