Save generated code in a special folder in “rtwbuild”

我的未来我决定 提交于 2019-12-04 04:03:31

问题


I am using rtwbuild to generated C++ code from a Simulation diagrams and would like to save generated code to an arbitrary directory. Is there any way to do so?


回答1:


You can control the folder for generated files in 3 different ways. You can set the "Code generation folder" option in Simulink Preferences. You can reach to Simulink preferences from any model using File menu and then choosing Simulink Preferences. This will change the code generation location for all models and will persist across MATLAB sesstions.

Second you can set a global param in MATLAB which will again control code generation directory for all models but will persist only for that MATLAB session. For example,

set_param(0, 'CodegenFolder', fullfile('C:','Work','mymodelrtw'))
get_param(0, 'CodegenFolder')

You can also use Simulink.fileGenControl object to set the codegen folder like the session param above. This object has more control about retaining previous folder paths and creating the folder optionally.

See the documentation for these at http://www.mathworks.com/help/rtw/ug/control-the-location-for-generated-files.html




回答2:


The generated code should be by default be in the a folder with the name of your model with some extension "_grt_rtw" or something else. So you are supoosed to know the default output folder. By using the following commands, you will be able to move or copy your files:movefile() copyfile()



来源:https://stackoverflow.com/questions/31801383/save-generated-code-in-a-special-folder-in-rtwbuild

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!