Documentation Center

  • Trial Software
  • Product Updates

genpath

Generate path string

Syntax

  • p = genpath
  • p = genpath(folderName) example

Description

p = genpath returns a path string, p, that includes all the folders and subfolders below matlabroot/toolbox, including empty subfolders.

example

p = genpath(folderName) returns a path string that includes folderName and multiple levels of subfolders below folderName. The path string does not include folders named private, folders that begin with the @ character (class folders), folders that begin with the + character (package folders), or subfolders within any of these.

Examples

expand all

Add Folder and Subfolders to Search Path

Use genpath in conjunction with addpath to add a folder and its subfolders to the search path.

Generate a path that includes matlabroot/toolbox/images/colorspaces and all folders below it.

folderName = fullfile(matlabroot,'toolbox','images','colorspaces');
p = genpath(folderName);

Add the folder and its subfolders to the search path.

addpath(p)

Input Arguments

expand all

folderName — Folder namestring

Folder name, specified as a string.

Example: 'c:/matlab/myfiles'

See Also

| |

Was this topic helpful?