Search path for the command ‘ Read ’

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


READPATH determines the directories, where the function read searches for files.

Possible values: String or a sequence of strings.

The variable READPATH can represent more than one search directory. This variable can be assigned a sequence of strings: each element of the sequence represents a directory in which files are search for.


When concatenated with a file name, the directories given by the path variables must produce valid path names.

Path names are slightly system dependent. You can separate subdirectories with a / on all systems. On Windows® systems, you may alternatively use a backslash character (\).

Note that in MuPAD®, a single backslash inside a character string is created by typing two backslashes. E.g., the MuPAD string representing the path “C:\Programs\MuPAD” must be defined by "C:\\Programs\\MuPAD".

The function pathname allows to create path names independent of the current operating system.


Example 1

This example shows how to define a READPATH. More than one path may be given. read will look for files to be opened in the directories given by READPATH. The following produces a valid READPATH for UNIX® and Linux® systems only, since the path separators are hard coded in the strings:

READPATH := "math/lib/", "math/local/"

It is good programming style to use platform independent path strings. This can be achieved with the function pathname:

READPATH := pathname("math", "lib"), 
            pathname("math", "local")

All path variables can be set to their default values by deleting them:

delete READPATH:

Example 2

The path variable WRITEPATH only accepts one path string:

WRITEPATH := "math/lib/", "math/local/"
Error: Invalid argument. [WRITEPATH]