필터 지우기
필터 지우기

Customize name of code generated called M-FIles

조회 수: 2 (최근 30일)
Marina Moreira
Marina Moreira 2017년 6월 1일
편집: Francesco 2020년 8월 13일
I have a simulink model containing Matlab Function blocks, these ones:
Inside the blocks I have code like this that calls other M-Functions saved in the same folder (this is just a simple example to ilustrate the problem).
My purpose is to generate code from the simulink model, I selected the ert.tlc system target file.
Because I want the called M-Functions (in this example would be the function sec_cuc) to be generated in different C-Files (no code inlining), I enabled the option 'Shared location', as seen in the picture below, which enables all the M-Functions to be saved in the same directory when the code is generated:
After generating the code, the generated files have the name :
knopohdjbiecbaaa_sec_cuc.c knopohdjbiecbaaa_sec_cuc.h (the first part of the names change with the different builds, making the generated code unreliable, they all have names like this with the first part to appear completely random and different from each other)
How can I customize the name or just take out the first part of the name with the random letters? My naming options configuration are:
I appreciate any help! Cheers

답변 (3개)

Fangjun Jiang
Fangjun Jiang 2017년 6월 1일
Right click the block, select "Block Parameters (Subsystem)", select the "Code Generation" panel, For "Function packaging", select "Reusable function", then you can set the "Function name options" and "File name options".
  댓글 수: 4
Marina Moreira
Marina Moreira 2017년 6월 2일
Thank you very much for your response, the name can be changed, however with that solution the generated code is very much terrible. (The purpose of my work is to investigate the code generation).
I will explain with your example: I have this model:
Whn I generate code I obtain these system files as I intended:
the problem Is that the function test, instead of calling directly the function rk4, calls a function in Subsystem.c (void Subsystem_rk4(real_T rtu_u, real_T rtu_v, real_T *rty_x, real_T *rty_y)) and that function calls the intended one (void rk4(real_T rtu_u, real_T rtu_v, B_rk4_T *localB)). With my previous method even though it had a weird name, it did not do this and the function was called directly.
As a footnote, I also tried this method with my working example (much more complex) and the generated code itself is not very good with useless variables, completely different from the one generated with my previous method. If there was a way of figuring out why the generated name is so weird it would be perfect so I have some idea how to change it.
Anyways, thank you very much for the help!
Aditya Shenoy
Aditya Shenoy 2018년 7월 15일
Me too facing the same Issue of Random name generation. Does any one has the solution for it?

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


Fabian Stein
Fabian Stein 2018년 4월 5일
How come no one from Mathworks can help here? This can not really be the intention!?
  댓글 수: 1
Andreas Goser
Andreas Goser 2018년 4월 13일
Fabian, MATLAB Answers is primarily a user-help-users forum and not a contact method to Technical Support. I saw you have contact support directly and will provide a first answer in a few minutes.

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


Francesco
Francesco 2020년 8월 13일
편집: Francesco 2020년 8월 13일
I have the same problem. Did anybody find a good solution to this problem? Still using Matlab 2017a

카테고리

Help CenterFile Exchange에서 Code Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by