pwd

Returns the current folder.

Category: Programming > Files and Folders

Syntax

pwd

Displays the current folder.

f = pwd

Returns the folder path as a character vector.

Description

The current folder is where a relative file name such as 'data.csv' is looked for. pwd returns its absolute path; combine it with fileparts to get just the folder name. Use cd to change it.

Output arguments

f
Full path of the current folder.

Example

Folder name of the current folder

mkdir lab
cd lab
[~, here] = fileparts(pwd)
Output
here = 'lab'

See also

cd fileparts dir fullfile