Main Content

addToProject

Add custom code and imported artifacts to MATLAB project

    Description

    success = obj.addToProject(ProjectFilePath), where obj is an object of class Simulink.CodeImporter or sltest.CodeImporter, adds the specified custom C/C++ code and the artifacts generated when importing custom code (using the import method) to an existing MATLAB® project. Generated artifacts include a Simulink® library and a data dictionary, and for objects of class sltest.CodeImporter, a sandbox folder. If you choose to generate a test harness and test files for the imported blocks, generated artifacts also include Simulink Test™ files (Simulink Test license required).

    Invoke addToProject only after a successful import of custom code.

    Input Arguments

    collapse all

    Name of existing MATLAB project, specified as a character vector or string scalar. The path can be a full path or a path relative to the current MATLAB folder. For addToProject to be successful, all custom code files and the Simulink library and other generated artifacts must be located in either the same folder as the MATLAB project or in direct or indirect subfolders of that folder.

    Data Types: character vector | string scalar

    Output Arguments

    collapse all

    Success indicator of whether code and artifacts are added to project, returned as a logical scalar. If not successful, Simulink throws an error.

    Version History

    Introduced in R2021a