uiputfile

Displays a file selection dialog.

Syntax

[name, filepath, index] = uiputfile()

[name, filepath, index] = uiputfile(info)

[name, filepath, index] = uiputfile(info, caption)

[name, filepath, index] = uiputfile(info, caption, defaultname)

Inputs

info optional
Specifyies the preferred file filter(s) or the default file name. If a file name is specified, it's extension will be used as the preferred file filter. File filters can also be specified using a cell array of strings with at least two columns; the first column giving the filter and the second column giving a description.
Type: string | cell
caption optional
Specifies the caption to be displayed for the dialog. If no caption is specified, the caption displayed will be Save File.
Type: string
defaultname optional
Specifyies the default name of the file to select.

Outputs

name
Name of the selected file.
Type: string
filepath optional
Output giving the path to the selected file.
Type: string
index optional
Output giving the filter index of the selected file.
Type: string

Examples

String input:
name = uiputfile('test.txt')
        
Default file filter displayed in the dialog is 'txt files (*.txt)'
String input with caption and default file name

                name = uiputfile('*.oml', 'Save My File', 'test.oml')

File name displayed will be 'test.oml', with file filter of 'oml files (*.oml)' and caption of 'Save My File'
Cell input:
[name, filepath, index] = uiputfile({'*.txt;*.dat','Text files';'*.oml','Compose files'}, 'Save My File')

Default file filter displayed in the dialog is 'Text files (*.txt;*.dat)