C-MEX S-Function Simulink Crash

4 Ansichten (letzte 30 Tage)
Daniel
Daniel am 30 Aug. 2012
Hello,
I generated an S-Function from C++ using the Legacy code to run in simulink. It does not work for all cases: If I change the input parameters or add a new block to run exactly as the existing block I get the message: Your model is still running. Do you want to close it? Yes/No. It does no matter what I choose and the program shuts down either way.
Can someone give me an explanation for that, and give me a hint in what I could do to avoid such behavior please?
I appreciate.

Akzeptierte Antwort

Kaustubha Govind
Kaustubha Govind am 30 Aug. 2012
Perhaps your C code is causing some memory corruption? You could try debugging your S-function to see which line the crash happens at - this will give you a better idea of what might be going on.
  2 Kommentare
Daniel
Daniel am 31 Aug. 2012
Hi Kaustubha,
Thank you.
If the code was causing memory corruption would not the simulation crashes every time? Or would not even be possible to compile? The fact is the S-function has been compiled and it works but not always.
What does it mean when Matlab pops up a message box with: "The model '' is still running. Do you want to stop and close it? Yes/No"? Clicking Yes or No yields to shutting the program down always.
Additionally C S-Functions do not give the same result as S-Functions from .m files. The plots of .m S-functions are continuous and smooth curves. The C S-Functions, on the other hand, give a "stairway" pattern as if it was discrete. Why do that happen?
Thank you again.
Kaustubha Govind
Kaustubha Govind am 4 Sep. 2012
Daniel: No, I've seen that memory corruptions can produce sporadic failures. (Note that they are usually run-time failures that cannot be detected by the compiler)
Your question about your C S-function producing a non-continuous waveform seems like a separate issue. Could you please create a new question for this? You might need to provide snippets of your MATLAB code and your equivalent C code for contributors to provide meaningful feedback.

Melden Sie sich an, um zu kommentieren.

Weitere 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