Borrar filtros
Borrar filtros

Simulink Code Generator - Preserve User Names

2 visualizaciones (últimos 30 días)
Simon C
Simon C el 12 de Abr. de 2021
Comentada: Simon C el 28 de Abr. de 2021
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.

Respuestas (1)

Meghna Chatterjee
Meghna Chatterjee el 14 de Abr. de 2021
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 comentario
Simon C
Simon C el 28 de Abr. de 2021
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by