userpath

Returns or sets the user's default working folder.

Category: Programming > Files and Folders

Syntax

p = userpath

Returns the folder as a character vector.

userpath(folder)

Sets it to folder.

userpath('reset')

Restores the default value.

Description

The user path is the folder where the program starts and the one that is always on the search path. It is where personal scripts and functions usually live. The value depends on the user, so use it to build paths rather than to compare against a literal text.

Input arguments

folder
Folder name, or 'reset' / 'clear'.

Output arguments

p
The user folder, usually Documents/MATLAB in the home folder.

Example

Reading the user folder

p = userpath;
ischar(p)
Output
ans = logical
   1

Notes

MatLivre supports reading the value.

See also

pwd cd path addpath