(Not recommended) Add folder and child files to project
Open the airframe project and create a project object.
sldemo_slproject_airframe proj = simulinkproject;
Create a new folder in the project folder.
new_folder_path = fullfile(proj.RootFolder, 'new_folder') mkdir(new_folder_path);
Create a new folder in the previous folder.
new_sub_folder_path = fullfile(new_folder_path, 'new_sub_folder') mkdir(new_sub_folder_path);
Create a new file in the folder.
filepath = fullfile(new_sub_folder_path, 'new_model_in_subfolder.slx') new_system('new_model_in_subfolder'); save_system('new_model_in_subfolder', filepath)
Add this new folder and child files to the project.
projectFile = addFolderIncludingChildFiles(proj, new_folder_path)
Project, specified as a project object. Use
simulinkproject to create
a project object to manipulate a project at the command line.
folder— Path of folder
Path of the folder to add relative to the project root folder, specified as a character vector or string. The folder must be within the root folder.
Not recommended starting in R2019a
Starting in R2019a, instead of
simulinkproject and related functions,
functions in MATLAB®. The Simulink® project API will continue to be supported, but, after R2019a, new features
might be available only if you use the new MATLAB project API. There are no plans to remove the Simulink project API at this time.
The new MATLAB project API is part of the R2019a functionality enabling you to use projects in MATLAB, with or without Simulink. You can now share projects with users who do not have Simulink.