How to enable the static variable in specified C files when using S-Function Builder tool

8 Ansichten (letzte 30 Tage)
Hello! As we know, the s-function builder block enable to run simulation based on user specified C source code.For example, I can link "mycode.c" to s-function builder tool then execute functions reside in "mycode.c" when doing simulation.Picture below shows you the setting I have made.
But now I have a problem. I found that the static variable declared in "mycode.c" seems not stay static in Simulink .
Since the static variable in "mycode.c" is important for my simulation. How to make the variable static in MATLAB environment? Thank you in advance!
  1 Kommentar
Arthur Preuss
Arthur Preuss am 23 Mai 2019
Hi yivan,
I am currently interested in a solution for this necessity.
A workaround that I made for my case, was to declare a function the would set or get the value of the static variable.
If you or someone else found an elegant solution for this problem, I would be glad to listen to.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by