Customizing Generated Code File Names in Simulink?

조회 수: 9 (최근 30일)
审言
审言 2025년 3월 17일
답변: Harsh 2025년 3월 24일
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?

답변 (1개)

Harsh
Harsh 2025년 3월 24일
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

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by