Customizing Generated Code File Names in Simulink?

5 Ansichten (letzte 30 Tage)
审言
审言 am 17 Mär. 2025
Beantwortet: Harsh am 24 Mär. 2025
My model is named Test, and in Simulink's Code Generation -> Code Placement, the automatically generated file naming rules are as follows:
  • Header file: $R$E
  • Source file: $R$E
  • Data file: $R_data
The generated files include:
  • Test.c
  • Test.h
  • Test_types.h
  • Test_private.h
When I replace $R with myModel, the generated files become:
  • myModel.c
  • myModel.h
  • myModeltypes.h
  • myModelprivate.h
I noticed that the underscore (_) disappeared in the last two files.
Is there any way to adjust the generated code file names so that they are different from the main model name?

Antworten (1)

Harsh
Harsh am 24 Mär. 2025
You can use a “Custom token text” to modify the name of the header, source and data files generated during code generation. Please follow the below steps to create and use a custom token:
  • In the Code Generation > Identifiers section, specify the “custom token text” in “advanced parameters”
  • In the Code Generation > Code Placement section, you can use the custom token by entering “$U” in “Auto-generated file naming rules”
  • Note that "$E" is mandatory for header and source files, representing instances for various file types such as dt, private, types, etc.
  • After making the above changes, you should be able to see “CustomToken” in your filenames as
You may refer to the following documentation page for “Custom token text” - https://www.mathworks.com/help/releases/R2024b/ecoder/ref/customtokentext.html

Kategorien

Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by