How to generate code for model without building included s-function

15 vues (au cours des 30 derniers jours)
James Orr
James Orr le 27 Août 2015
Modifié(e) : Rutuja Shirali le 31 Août 2015
Hello, and thanks for your time.
I would like to generate external code for the General Real-Time Target that references an S-function that isn't built at code-generation time.
The S-function we're using can't be built on the same computer that we're developing our Simulink model on, because we don't have access to the libraries that are required. (I.e. we can't build our S-function because we'd get linker errors, and we can't resolve those errors.)
However, the S-function builder can generate code, and Simulink can generate code, so I thought it should be possible to generate the code for both, move them to the final destination, and build everything together (with the third-party libraries present) at that point in time. Unfortunately, if you try to generate code for a Simulink model that contains an unbuilt S-function you just get the error "S-function does not exist". This doesn't really make sense- is the complied version of the S-function really required to just generate code for the Simulink model?
Is there any way we can configure Simulink to let us generate code in this situation?
Thanks in advance, James

Réponses (1)

Rutuja Shirali
Rutuja Shirali le 31 Août 2015
Modifié(e) : Rutuja Shirali le 31 Août 2015
I understand that you want to build a Simulink Model which consists of an S-function that depends on external libraries. We cannot build a Simulink model which contains an unbuilt S-function and the error that you see is an expected behavior. However as per my understanding, you will need to build the S-function using the S-function builder on the machine which has all the required libraries and then deploy the Generated S-Function Block. More information about this can be found in the "Deploying the Generated S-Function" section on the following page:
Also, I believe that you want to create Wrapper S-function that inline a call to your algorithm, this would require the "s-function.tlc" file to be present while building your Simulink model. Make sure that you have the basic files mentioned on the following page required for the Implementation:
Once this is done, you can then build the entire model which includes the built S-function.
"Legacy Code Tool" can also be used as an alternative to S-Function Builder to build and deploy S-function and it is recommended. More information about Legacy Tool can be found here:

Community Treasure Hunt

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

Start Hunting!

Translated by