getRootDirectory

Class: Simulink.ModelManagement.Project.CurrentProject
Package: Simulink.ModelManagement.Project

(To be removed) Get the name of the root folder for the currently open Simulink project

    Note:   getRootDirectory will be removed in a future release. Access the RootFolder property of a project object instead. Use simulinkproject to get a project object.

Syntax

p = Simulink.ModelManagement.Project.CurrentProject()
p.getRootDirectory

Description

p = Simulink.ModelManagement.Project.CurrentProject() creates an instance of the CurrentProject class.

p.getRootDirectory returns the name of the root folder for the currently open Simulink project.

This method is particularly useful when creating start up and shutdown scripts, or functions, for a project. Use this method to determine the project root folder so that sub-folders of the project can be added to the MATLAB path without using absolute paths.

Example

To get the name of the root folder for the currently open Simulink project, use the following commands.

  1. Create an instance of the CurrentProject class.

    p = Simulink.ModelManagement.Project.CurrentProject();
  2. Use the getRootDirectory method.

    p.getRootDirectory;
Was this topic helpful?