How can I control the autocode names for matlab m files?

조회 수: 6 (최근 30일)
Luis Cordova
Luis Cordova 2020년 7월 1일
답변: Himanshu 2024년 10월 22일
I think I found the process for controlling the C autocode file/function name for matlab .slx models. However, how do I control the autocode file/function name for matlab .m files?
For example, this simple matlab .m file/function is called: function [Angle_Out] = eml_Wrap_Angle(Angle_In)
When autocoded, it first showed up as:
eml_Wrap_Angle_BYuy7qQF.h & .cpp.
After updating:
cs.set_param('MATLABFcnDesc', 'off');
from off to on to show the matlab comments in the C++ autocode, the name changed to this:
eml_Wrap_angle_hMfilaPR.h & .cpp.
We have some google tests where we use the old file/function names. It would be a lot of work for us to update these names in all the google tests. I would rather not, but if we have to, is it possible to get autocode names without the random name portion added? Or better yet, why did the random name portion change after simply changing the MATLABFcnDesc option? I would not have expected that. That might be a matlab bug.

답변 (1개)

Himanshu
Himanshu 2024년 10월 22일
Hey,
Changing code generation settings, such as turning certain features on or off, can influence the internal state and metadata during code generation, potentially resulting in different unique identifiers.
A configuration object allows you to define various settings that affect code generation behavior, including naming conventions. To create a configuration object for code generation, use coder.config.
cfg = coder.config('lib'); % Use 'lib' for library generation, or 'dll', 'exe', etc.
Utilize the CustomSymbolStrFcn property to establish a custom naming pattern for functions, which helps determine how functions are named in the generated code.
matlab
cfg.CustomSymbolStrFcn = 'eml_Wrap_Angle';
Additionally, I recommend using the latest version of MATLAB for code generation. I recently generated code for a function in MATLAB R2024a, and I noticed that the identifiers are not present in the file names. The files are simply named <functionname>.cpp and <functionname>.h.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by