How can I control the autocode names for matlab m files?
7 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!