Using non reusable functions for referenced models

조회 수: 16 (최근 30일)
Caroline Brandberg
Caroline Brandberg 2018년 3월 15일
댓글: Jesús Zambrano 2022년 2월 2일
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?

답변 (1개)

Jesús Zambrano
Jesús Zambrano 2020년 2월 7일
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
Bogdan Bodnarescu
Bogdan Bodnarescu 2022년 2월 2일
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 2022년 2월 2일
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

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

Community Treasure Hunt

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

Start Hunting!

Translated by