Functions reuse in generated code

I have a Simulink 2014a model that contains two identical subsystems from a user-defined library. For these subsystems, function packaging parameter is set to reusable. One of the subsystems inputs are fed by constant block, while the other subsystem inputs are fed by gain blocks. In the generated code (using embedded coder), the functions generated for the two subsystems aren't being reused. When comparing subsystem checksum, I noticed that "ReadsInputInStartFcn" identifier is different between the two subsystems. Note that, I am using a "MATLAB Function (fcn)" block in both subsystems. Could you please explain the root cause of this difference?

댓글 수: 6

Birdman
Birdman 2017년 12월 13일
Can you please share the model?(Export to r2017a)
Amr Nagaty
Amr Nagaty 2017년 12월 13일
I don't have access to r2017a. But, I attached a screenshot of the subsystem I am trying to generate code for.
Birdman
Birdman 2017년 12월 14일
But inside of subsystems are more important for this question. Can you also share them?
Amr Nagaty
Amr Nagaty 2017년 12월 14일
The inside is attached, it is just a MATLAB function block with some trivial calculation inside. It seems that the generated code is not being reused because (Aq_B, v_B) for one subsystem are fed directly by constant blocks. While for the other subsystem, they are fed by a gain block. Is there a way to still make the generated code reusable?
Birdman
Birdman 2017년 12월 14일
I still need to see what is written inside each MATLAB Function block for two subsystems respectively.
Walter Roberson
Walter Roberson 2017년 12월 14일
R2017a can open models created in R2014a, so if you could attach your model and associated .m files then we could explore them. Birdman would just have difficulty opening the files if they had happened to have been created with R2017b.

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

답변 (1개)

Juan Rafael Garcia Blanco
Juan Rafael Garcia Blanco 2019년 8월 28일

1 개 추천

I have the same problem. I have got around this problem by inserting a Signal Conversion block in between the Constant block and the atomic block. I have checked that it does not introduce any additional code, and this way, EC seems to understand that the two blocks are effectively the same and generates a single C function.

카테고리

도움말 센터File Exchange에서 Subsystems에 대해 자세히 알아보기

제품

질문:

2017년 12월 13일

답변:

2019년 8월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by