S Mex function global variable values

Hello,
I have legacy C code with many global variables, which is bound into simulink be means of Mex-S-function.
When I stop and restart simulation I would expectd that new process is created and all those variables are to there init value (most of them 0, because not explicitely set and so on).
If I just start and stop and start it is unfortunately not the case.
If I start, stop, then rebuild S-function by "mex" command and then start it is the case.
Is there any way to say Simulink to unload the process on each simulation stop/end (I mean stop, not pause of course)?
Thanks,

댓글 수: 4

James Tursa
James Tursa 2020년 7월 15일
Can't you just clear the mex function from memory?
Lila Lotus
Lila Lotus 2020년 7월 15일
How could I do i? It looks like a normal block in simulink. How do i delete it from memory without changing a model?
James Tursa
James Tursa 2020년 7월 16일
편집: James Tursa 2020년 7월 16일
Does the mex function itself show up in the list generated by the inmem( ) function? E.g.,
[M,X] = inmem;
Does it show up in the X list?
Use
clear all
everytime you run a simulation.
But this is not optimal as many others would suggest.

댓글을 달려면 로그인하십시오.

답변 (1개)

Lila Lotus
Lila Lotus 2020년 7월 16일

0 개 추천

Thank you, clear mex did the job

카테고리

도움말 센터File Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품

질문:

2020년 7월 15일

답변:

2020년 7월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by