Main Content

addShortcut

R2026b

Add shortcut to project

Description

shortcuts = addShortcut(proj,files) adds shortcuts to the specified files in the project. In projects, a shortcut can be used to perform common project tasks such as opening important files and loading data.

To set the shortcut to run at startup or shutdown, see Automate Startup and Shutdown Tasks.

example

shortcuts = addShortcut(proj,files,Name=Value) adds shortcuts to the specified files in the project and specifies additional options as one or more name-value pair arguments.

Examples

collapse all

Open the Times Table App project. Use currentProject to create a project object from the currently loaded project.

openExample("matlab/TimesTableProjectExample")
proj = currentProject;

Create a new file.

filepath = fullfile(proj.RootFolder,"newvariables.mat");
save(filepath)

Add this new file to the project.

projectFile = addFile(proj,filepath)

Add a new shortcut to the new file.

shortcut = addShortcut(proj,filepath);
shortcut = 

  Shortcut with properties:

     Name: "newvariables"
    Group: "General"
     File: "C:\myProjects\examples\TimesTableApp\newvariables.mat"

Input Arguments

collapse all

Project, specified as a matlab.project.Project object. Use currentProject to create a project object from the currently loaded project.

Path of the shortcut files, including the file extension, specified as a string array or a cell array of character vectors. The files must be within the project root folder. If the file is not a project file, the function adds it to the project.

Name-Value Arguments

collapse all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: Name="myShortcutName"

Since R2026b

Names of the shortcuts to add, specified as a string array or a cell array of character vectors. The size of this array must be equal to the size of the files argument. Each element corresponds to the shortcut file at the same position in the files argument.

Data Types: char | string

Since R2026b

Name of the new or existing group for the shortcuts, specified as a character vector or string scalar.

Data Types: char | string

Output Arguments

collapse all

Shortcuts, returned as an array of Shortcut objects.

Version History

Introduced in R2019a

expand all