How to change the name of external inputs (ExtU)/outputs (ExtY) in generated code [R2023b]?

조회 수: 6 (최근 30일)
Hello everyone,
I can't find a way to change the name of the external inputs and external outputs.
Everytime I generate code I get:
  • For the inputs:
struct ExtU {
float _accelX; // '<Root>/_accelX'
float _accelY; // '<Root>/_accelY'
float _accelZ; // '<Root>/_accelZ'
};
  • For the outputs:
struct ExtY {
bool _shockDetected; // '<Root>/_shockDetected'
};
How can I go about doing this without modifying the code by hand?
Thanks in advance

답변 (1개)

Omega
Omega 2024년 7월 11일
Hi,
To change the names of the external inputs (ExtU) and outputs (ExtY) in the generated code in MATLAB R2023b, you can use the Code Mappings editor or the command-line API to configure the names of the data elements. Here’s how you can do this using the Code Mappings Editor:
1. Open the Model: Open your Simulink model.
2. Open Code Mappings Editor:
  • Go to the Apps tab in the Simulink model window.
  • Select Embedded Coder.
  • In the C Code tab, click on Code Interface > Default Code Mappings.
3. Configure External Inputs and Outputs:
  • In the Code Mappings editor, go to the Inports/Outports tab.
  • For each input port, you can set the Storage Class and Identifier in the Code section of Property Inspector. The Identifier is the name that will be used in the generated code.
  • Similarly, for each output port, set the Storage Class and Identifier.
NOTE:
  • Storage Class: The storage class parameter should be set to 'ExportedGlobal' or another appropriate storage class('Model Default') to ensure that the identifier is used in the generated code.
  • Identifier: The Identifier parameter specifies the name that will appear in the generated code.
If you would like to control the names of the struct type then you can refer to the following documentation link:

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

태그

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by