Inconsistent code generation of Block parameters with Embedded Coder
조회 수: 4 (최근 30일)
이전 댓글 표시
I'm trying to generate C++ code via Embedded Coder.
This simple model contains some variables a,b,b1, where their constant values are implicitly set under .mat file
#
This is one of the block parameters:
When I generate code, I get the following
// Parameters (default storage)
struct P_controller_module_T {
double a; // Variable: a
// Referenced by: '<Root>/a'
double b; // Variable: b
// Referenced by: '<Root>/b'
double b1; // Variable: b1
// Referenced by: '<Root>/b1'
};
However in another model I have the following block parameters (constant values are also implicitly set under .mat files) :
But when generating code I get the following :
double Kp_lat_Value; // Expression: Kp_lat
// Referenced by: '<S11>/Kp_lat'
How do I keep the suffix "_Value" consistent ?
댓글 수: 1
prabhat kumar sharma
2024년 6월 3일
I suggest comparing the code generation properties. Go to the Modeling tab, select Model Properties, then Code Generation. Comparing all the attributes in both models will likely identify the attribute affecting this.
답변 (1개)
Abhas
대략 15시간 전
To ensure consistent naming of parameters in the generated C++ code using Embedded Coder, follow these steps:
- Configure Code Generation Settings: Open your Simulink model, go to "Modeling" > "Model Settings", and navigate to "Code Generation" > "Identifiers". Set the naming conventions for parameters to include the suffix "_Value".
- Set Identifier Format Control: In the "Identifiers" section, ensure that the naming rule for parameter identifiers specifies the desired suffix, such as "_Value".
- Use Data Dictionaries or Workspaces: Ensure that parameters defined in a .mat file are correctly linked to the model using a Simulink Data Dictionary or the base workspace, and that their names match the desired convention.
- Review Parameter Naming Rules: For MATLAB variables or Simulink.Parameter objects, define them with the desired suffix in the model workspace or data dictionary, and set their "CoderInfo.StorageClass" to an appropriate class like "ExportedGlobal".
You may refer to the below MathWorks documentation link to know more abut Code Generation Identifiers: https://www.mathworks.com/help/ecoder/ref/code-generation-pane-symbols.html
I hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Deployment, Integration, and Supported Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!