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

6 visualizzazioni (ultimi 30 giorni)
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

Risposte (1)

Omega
Omega il 11 Lug 2024
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:

Categorie

Scopri di più su Simulink Coder in Help Center e File Exchange

Tag

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by