MATLAB Answers

How do I keep unused root-Level Inports in the generated code

10 views (last 30 days)
Sergio Delgado
Sergio Delgado on 7 Jan 2021
Commented: Sergio Delgado on 15 Jan 2021
Dear Community,
I have been looking for a simple solution to my problem, but cannot quite find the right approach.
I am generating C-Code using the Embedded Coder for a simple Algorithm. Now, the problem is that I want to fix the the number of inputs in the generated code, even if a particular input-signal remains unused. The background is that the algorithm is going to change over time but the interface should remain unchanged, because the C-function I am generating is embedded in a larger project.
When I generate the code, the number of arguments in the "step" function change, because the unused input signals are dropped (they get optimized).
My solution was to create a test point for the unused input signal. The problem is that a test point generates the "B-structure" in the code, which I don't want either.
So, my question is: is there a way to fix the root-level inports as inputs in the generated code regardless whether they are used or not?
I cannot find that checkbox in the configuration parameters.
Additional Info: I generate Code programatically, so using the App or the Simulink Interface is unfortunately not an option.
Thanks in advance!

  0 Comments

Sign in to comment.

Answers (1)

Fangjun Jiang
Fangjun Jiang on 7 Jan 2021
In your model configuration, search for "block reduction", un-check it.
I assume you must have the root-level Inport blocks terminated somewhere. I was hoping this note in the help document of "block reduction" is relevant.
Dead Code Elimination. Any blocks or signals in anunused code path are eliminated from generated code.

  1 Comment

Sergio Delgado
Sergio Delgado on 15 Jan 2021
Hello, Thanks for your answer.
This is the configuration file I am using (see attachment)
The "Block Reduction" is unchecked... still, the input arguments of the step-Function are gone.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!