FUNCTION REFERENCE

uigetfile

Ask the user to pick a file to open.

Ask the user to pick a file to open.

Syntax

[file, path, indx] = uigetfile(filter, title, defname)

Syntax

[file, path, indx] = uigetfile(..., 'MultiSelect', 'on')

filter is a pattern such as '*.csv', several patterns joined with ';' ('*.m;*.txt'), a folder or path to start in ('data/*.csv'), or a cell array with one filter per row and an optional second column of labels ({'*.csv', 'CSV files'; '*.*', 'All files'}). A plain file name as filter ('results.csv') is prefilled and its extension is the filter. defname names the file selected at first and may include a folder; without a folder the picker starts in the current folder. file is the file name, path its folder with a trailing separator and indx the filter number; on Cancel all three are 0. With MultiSelect on and several files picked, file is a cell row of names. The desktop app shows the system file picker (on Linux through the XDG desktop portal, for example xdg-desktop-portal-gtk, or zenity; without either the call fails and names the packages); in -batch mode, the terminal and the browser the call fails with "dialogs need the desktop app".

Example

[f, p] = uigetfile('*.csv', 'Pick a data file');

Differences from MATLAB: indx is the first filter that matches the picked file's extension, because the system picker does not report the chosen filter. When no filter matches the name, indx is 0 and file and path are still returned.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.