Simulink address prefix while using embedded coder

Hello,
I am working with Simulink and Embedded Coder, generating code for use with a calibration tool. My model name is abc, and in the generated code the variables are accessed as abc_DW.varname.
I would prefer to have flat global variable names like varname, without the model-based prefix or struct (such as abc_DW).
I understand that Simulink organizes data into structures like DW, B, etc., but I would like to avoid this and have direct global variables instead.
Is it possible to remove this prefix and struct-based access through model settings? If so, which configuration parameters control this behavior?
Also, is using storage classes like ExportedGlobal the recommended approach, or is there a way to disable structured data globally? I would prefer not to use this approach.
I am using Embedded Coder (ERT target), and the variables need to be accessible in a calibration tools.
Any guidance would be helpful.
Thank you,
Rahul R

Answers (1)

Hello @Rahul,
I see you're trying to generate flat global variable names like "varname" in your Embedded Coder output instead of the default structured format "abc_DW.varname" so that your calibration tool can access the variables directly without the model prefix and struct wrapper.
I think the structured naming is happening because Embedded Coder uses structured storage types (like the DW struct) by default to organize signals, states, and parameters. The documentation- Use Built-In and Predefined Storage Classes to Represent Data in Generated Code - MATLAB & Simulink, explains that storage classes have a "Storage Type" property that can be either "Structured" (uses structs) or "Unstructured" (flat globals).
You could try:
Use the "ExportedGlobal" storage class - this is the built-in solution for your exact requirement:
  1. For each variable you need in your calibration tool:
  • Open Model Data Editor
  • Select the parameter, signal, or state
  • Set Storage Class to ExportedGlobal
2. What this does:
  • Storage Type: Unstructured (no struct wrapper)
  • Data Scope: Exported (globally accessible)
  • Generates: extern datatype varname; in model.h and datatype varname = value; in model.c
  • This gives you the flat "varname" format instead of abc_DW.varname
3. Alternative options if you need different file placement or behavior:
Why not disable structures globally: It is mentioned in the documentation that structured storage classes (like Struct, MultiInstance) exist to organize code and prevent naming conflicts. The recommended approach is to selectively use unstructured storage classes (like ExportedGlobal) for variables that need external access, while keeping the rest structured.
Let me know if this helps!

Categories

Find more on Deployment, Integration, and Supported Hardware in Help Center and File Exchange

Products

Release

R2025a

Asked:

on 15 Apr 2026 at 6:24

Answered:

on 20 Apr 2026 at 15:42

Community Treasure Hunt

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

Start Hunting!