Save the generated code in a special folder in "rtwbuild"

I am using rtwbuild

for generated C ++ code from simulation diagrams and would like to save the generated code to an arbitrary directory. Is there a way to do this?

+3


source to share


2 answers


You can manage the folder for the generated files in three different ways. You can set the "Code Generation" option in the Simulink settings. You can navigate to Simulink settings from any model using the File menu and then select Simulink Settings. This will change the location of the code generation for all models and will persist across MATLAB traits.

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

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

      



You can also use the Simulink.fileGenControl object to set the codegen folder like the session parameter above. This object has more control over the preservation of previous folder paths and the ability to create a folder.

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

+3


source


The generated code by default should be in a folder with your model name with some extension "_grt_rtw" or something else. This way you are overridden to find out the default output folder. Using the following commands, you can move or copy files:movefile() copyfile()



0


source







All Articles