필터 지우기
필터 지우기

Simulink Code Generator - Preserve User Names

조회 수: 2 (최근 30일)
Simon C
Simon C 2021년 4월 12일
댓글: Simon C 2021년 4월 28일
Using Version 2018b, is there a way to use the "Preserve User Names" for "code" in a MATLAB function (as the help indicates is in the MATLAB encoder for code generation)?
Looking at the code generated out of the Simulink Code generation, I can see that it makes decisions on removing locally declared variables. These have been added to avoid repeating calculations throughout the script therefore reducing the number of function calls required. However, when these are optimised in code generation, the labels are used in a different order meaning the code is now misleading . Now this could be fixed by not using meaningful names in the Matlab function script in the first place, but that's not acceptable really. When I have to debug this code, I want to be able to read it as intended.

답변 (1개)

Meghna Chatterjee
Meghna Chatterjee 2021년 4월 14일
Hi Simon,
To control the names of the structures in the generated code, you need an Embedded Coder® license. To instead store a data item in a separate global variable whose name, file placement, and other characteristics you can control, you can apply a storage class to a signal, state, or Simulink.Parameter object. See C Code Generation Configuration for Model Interface Elements and Configuring Data Accessibility for additional explanation and steps.
  댓글 수: 1
Simon C
Simon C 2021년 4월 28일
Thanks, this is a problem when using Matlab script in a function block, so nothing needs to be saved to the Workspace and is not using external structures or the parameters. Really just pointing out that the 'optimisation of local variables' in the code generation should be able to be turned on/off, in order to maintain the intent of the script in the function block.

댓글을 달려면 로그인하십시오.

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by