Using non reusable functions for referenced models

16 views (last 30 days)
Hi,
I'm using a Simulink model which contains referenced models and I would like to generate non-reusable functions for all models. It seems like it only works on the "top level". I have the settings "nonreusable function" for all models, but the generated code will be something like the following:
ert_main.c: my_model_step();
my_model.c: my_model_step() { ref_model_f(...); }
ref_model.c: ref_model_f(...) { ... }
Is there any settings which allows the referenced model to have a function declaration without any parameters, i.e., to make them non-reusable?

Answers (1)

Jesús Zambrano
Jesús Zambrano on 7 Feb 2020
Hi Caroline,
I suggest you work with atomic subsystems. With them, you will have the option of setting the function packaging to Reusable or Nonreusable.
  21 Comments
Bogdan Bodnarescu
Bogdan Bodnarescu on 2 Feb 2022
Hello @Jesús Zambrano and thanks for the answer.
Indeed ExportToFile makes the code as I want it, but this is not the solution that I like because of the very high amount of manual work that I have to do to configure all the Inports and Outports manually.
It would have been really nice that the fields in the Property Inspector have a drow down lists from which to select, probably this could be done programatically with a script to set everything up.
Still I am not happy that a separate .c file is generated for the referenced models on the same level where the top model is, for my project this is not happenning.
Honestly I would have prefered to have all my Inports and Outports to be configured as ExportedGlobal and that they are automatically defined in the modules, or at least that there is some easy way to do this.
Could this work if I make a Custom Storage Class?
Jesús Zambrano
Jesús Zambrano on 2 Feb 2022
Yes, you could try with Custom Sotrage Class.
As mentioned before, to get a full and detailed guidance of exactly the solution you want, try with tech support. Another good solution is to contact the MathWorks sales rep. assigned to your company, the IT department at your company surely has this information.
All the best,
Jesús

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!