Clear Filters
Clear Filters

Is it possible to add a C wrapper to a SFunction?

2 views (last 30 days)
Is it possible to add a C wrapper to a SFunction? How do i create the SimStrut of a particular model? Because all the functions in SFunction target have an input argument SimStruct *S. So if i have to invoke a function, then i need to pass the argument *S to it. Can you please tell me how to do it?

Accepted Answer

Kaustubha Govind
Kaustubha Govind on 19 Mar 2013
I don't believe it is currently possible to execute S-functions outside of the Simulink environment. the SimStruct data structure is allocated and managed by the Simulink Engine, and cannot be created by an external process. I would recommend that you refactor your S-function code such that the main algorithm is in a separate C-file (that is free of Simulink specific concepts like SimStruct) and call that from the S-function instead. This way, the C code can be shared by the S-function as well as other clients.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!