Pathname of a file that is currently loaded
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.
FILEPATH is a variable containing the path
of a currently read file.
Possible values: String
FILEPATH represents the pathname
of a file. It only has a value while reading a file via
fread and corresponds
to the path specified in
fread. It can only be
accessed from inside the file that is currently read. Using this variable,
the read file can access its own pathname and read other files via
absolute pathnames, even if it only knows their relative locations
with respect to itself.
The value of
FILEPATH is a string containing
the operating system dependent path to the file that is currently
read. The path string terminates with a path separator and, under Windows®,
starts with the name of the current volume if this was specified in
fread command. Cf. Example 1.
Assume that the file
the following lines of code. It queries its own location via
and reads two files installed relative to the location of
their absolute pathnames
print(Unquoted, "FILEPATH" = FILEPATH): read(FILEPATH.pathname("SubFolder")."file1.mu"): read(FILEPATH.pathname("SubFolder")."file2.mu"):
When reading the file
file.mu, the part
the specified path is accessed by
It finds the files
they were installed correctly relative to the path of
read("C:".pathname(Root, "TEMP"), "file.mu")
FILEPATH = C:\TEMP\
It is good programming style to use platform independent path
strings. For this reason, we used the function
pathname rather than a mere string concatenation
to append appropriate path delimiters.