This Simulink project follows a structured organization pattern to maintain consistency and facilitate collaboration. The project uses a standardized folder structure for models and their associated artifacts.
Project Root/
├── cache/ # Cached files and temporary data (automatically used by Simulink)
├── codegen/ # Generated code from models (automatically used by Simulink)
├── data/ # Project-level data files
├── doc/ # Project-level documentation
├── internal/ # Internal utilities and templates for the project itself
│ ├── createNewModel.m # Model creation utility function
│ ├── newModelTemplate.slx # Template for new models
│ └── newSubsystemTemplate.slx # Template for new subsystems
├── models/ # Contains all Simulink models and subsystems
├── requirements/ # Project-level requirements
├── test/ # Project-level test files
├── utilities/ # Utility functions and scripts
├── work/ # Working directory for temporary files
├── resources/ # DO NOT EDIT - automatically managed by MATLAB
├── SimulinkProjectFileStructure.prj # MATLAB Project file
└── README.md # This file
Each model or subsystem created using the createNewModel function follows a consistent folder structure within the models/ directory:
models/
└── <ModelName>/ # Root folder for the model
├── <ModelName>.slx # Simulink model/subsystem file
├── <ModelName>_harnessInfo.xml # DO NOT EDIT - Test harness information (if Simulink Test available), automatically maintained by Simulink Test
├── data/ # Data and configuration files
│ └── <ModelName>.sldd # Simulink Data Dictionary, attached to <ModelName>.slx
├── doc/ # Documentation specific to this model
├── requirements/ # Requirements and specifications for this model
└── test/ # Test-related artifacts
├── harnesses/ # Test harnesses
│ └── <ModelName>_harness.slx # Test harness (if Simulink Test available)
├── data/ # Test data files
└── <ModelName>_Tests.mldatx # Test Manager file (if Simulink Test available)
The createNewModel function automates the creation of new models or subsystems with the proper folder structure and associated files.
% Create a new model (default)
createNewModel("MyModelName")
% Explicitly create a model
createNewModel("MyModelName", "Type", "Model")
% Create a subsystem
createNewModel("MySubsystemName", "Type", "Subsystem")- mdlName (required): String specifying the name of the model or subsystem to create
- Type (optional): Either "Model" or "Subsystem" (default: "Model")
When you run createNewModel, it automatically:
-
Creates the complete folder structure under
models/<ModelName>/:models/<ModelName>/- Root folder for the modelmodels/<ModelName>/data/- For data dictionaries and configurationmodels/<ModelName>/doc/- For model-specific documentationmodels/<ModelName>/requirements/- For requirements documentsmodels/<ModelName>/test/- For test artifactsmodels/<ModelName>/test/harnesses/- For test harnessesmodels/<ModelName>/test/data/- For test data
-
Creates the Simulink model/subsystem:
- Uses templates from the
internal/folder (newModelTemplate.slxornewSubsystemTemplate.slx) - Saves as
<ModelName>.slxinmodels/<ModelName>/
- Uses templates from the
-
Creates and links a Simulink Data Dictionary:
- Creates
<ModelName>.slddinmodels/<ModelName>/data/ - Automatically attaches it to the model
- Creates
-
Creates test artifacts (if Simulink Test is licensed):
- Test harness:
<ModelName>_harness.slxinmodels/<ModelName>/test/harnesses/ - Harness info:
<ModelName>_harnessInfo.xmlinmodels/<ModelName>/ - Test file:
<ModelName>_Tests.mldatxinmodels/<ModelName>/test/
- Test harness:
-
Adds all created files and folders to the project:
- Automatically registers all files with the Simulink project
- Adds all folders to the project path
% Create a new model called "ControlSystem"
createNewModel("ControlSystem")
% This creates the following structure:
% models/
% └── ControlSystem/
% ├── ControlSystem.slx
% ├── ControlSystem_harnessInfo.xml # (if Simulink Test available)
% ├── data/
% │ └── ControlSystem.sldd
% ├── doc/
% ├── requirements/
% └── test/
% ├── harnesses/
% │ └── ControlSystem_harness.slx # (if Simulink Test available)
% ├── data/
% └── ControlSystem_Tests.mldatx # (if Simulink Test available)- Must be run within an active Simulink Project
- Project must have a
models/folder at the root level - Templates (
newModelTemplate.sltxandnewSubsystemTemplate.sltx) must exist in theinternal/folder - Simulink Test license required for test artifact creation (optional - function will still work without it)
- Consistency: All models follow the same organizational structure
- Automation: Reduces manual setup time and potential errors
- Best Practices: Enforces separation of concerns (data, docs, tests, requirements)
- Scalability: Makes it easy to manage multiple models in large projects
- Project Path Management: Automatically adds all folders to the project path for easy access
- The function will create all folders even if they remain empty initially
- All created artifacts are automatically added to the Simulink project
- Test artifacts are only created if Simulink Test toolbox is licensed
- The model templates in the
internal/folder can be customized to match your organization's standards - Generated code from models will be stored in the project-level
codegen/folder