uiputfile — Open a host save-file dialog and return the selected file name and path.
uiputfile requests a save-file target from the selected RunMat session host and returns MATLAB-compatible output values. Interactive hosts can implement the typed hook to show a native or browser save picker; noninteractive sessions return the standard cancellation values.
Syntax
file = uiputfile()
file = uiputfile(filter)
[file, path] = uiputfile(filter, title)
[file, path, index] = uiputfile(filter, title, defaultName)Inputs
filter- Type
Any- Required
- No
- Default
"*.*"- Description
- File extension pattern, semicolon-delimited patterns, or an N-by-1/N-by-2 cell array of patterns and descriptions.
title- Type
StringScalar- Required
- No
- Description
- Dialog title.
defaultName- Type
StringScalar- Required
- No
- Description
- Initial file or directory path for the dialog.
Returns
file- Type
Any- Description
- Selected filename, or 0 when cancelled.
path- Type
Any- Description
- Directory containing the selected file, including a trailing separator, or 0 when cancelled.
index- Type
NumericScalar- Description
- One-based selected filter index, or 0 when cancelled.
Errors
RunMat:uiputfile:InvalidArgument- When
- A filter, title, or default path has an unsupported type or shape.
- Message
uiputfile: invalid argument
RunMat:uiputfile:TooManyOutputs- When
- More than three output arguments are requested.
- Message
uiputfile: too many output arguments
RunMat:uiputfile:HostError- When
- The active filesystem provider fails while opening the host save-file UI.
- Message
uiputfile: file selection failed
RunMat:uiputfile:InvalidSelection- When
- The active filesystem provider returns a malformed save-file selection.
- Message
uiputfile: invalid file selection
Calling forms and results
file = uiputfile() uses an all-files filter.
uiputfile(filter) accepts a character vector, string scalar, semicolon-delimited pattern list, or an N-by-1/N-by-2 cell array of patterns and descriptions.
uiputfile(filter, title, defaultName) forwards the dialog title and initial file or directory path to the selected session host.
The selected path output is the containing directory with a trailing path separator. The index output is a one-based integer-valued double, not a native integer-class result.
Inputs are textual. Host or provider-resident numeric values are rejected before the save-file request is made.
Cancellation returns numeric zero for file, path, and index, matching MATLAB. This is also the behavior when the selected session host does not implement a save-file picker.
Host text and filter cells are validated before any dialog request. Genuine character or cell pages reject; trailing singleton dimensions retain their effective row/matrix shape. Numeric resident values are not text and do not trigger a gather.
Requesting more than three outputs rejects before opening the dialog. Requesting zero outputs still performs the host interaction and validates its result.
Host integration
No. Save-file dialogs are host/UI operations and always execute outside GPU residency. The provider hook returns a path in the active filesystem namespace, so browser hosts should map save targets into the mounted provider namespace before returning the path.
Host interaction is an effectful callback and fusion boundary, not GPU computation or a distributed worker task. Interactive examples use typed DesktopHost fixtures; headless cancellation does not verify an actual picker.
Examples
Choose a MAT-file destination
value = 42;
[file, path] = uiputfile('*.mat', 'Save workspace');
assert(strcmp(file, 'results.mat'));
save(fullfile(path, file), 'value');
assert(isfile(fullfile(path, file)));Use multiple filters
filters = {'*.mat', 'MAT-files'; '*.txt', 'Text files'};
[file, path, index] = uiputfile(filters, 'Export data', 'results.mat');
assert(strcmp(file, 'report.txt'));
assert(index == 2);Handle cancellation
[file, path, index] = uiputfile;
assert(isequal(file, 0)); assert(isequal(path, 0)); assert(isequal(index, 0));Using uiputfile with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how uiputfile changes the result.
Run a small uiputfile example, explain the result, then change one input and compare the output.
FAQ
What happens in noninteractive or headless RunMat hosts?⌄
The runtime returns numeric cancellation zeros when the selected session host has no picker. An interactive session host implements select_file_save.
How does a browser host provide a real save picker?⌄
The host must connect its interactive picker to the runtime's host-dialog service and return paths in the active filesystem namespace. Filesystem storage alone does not install a picker. Native host-dialog requests and selections are typed; browser applications need the corresponding host bridge.
Does uiputfile write the selected file?⌄
No. It only returns the selected file name and directory. Use fullfile(path, file) with save, fopen, writematrix, or another file-writing builtin to create the file.
Related Io functions
Repl Fs
addpath · cd · copyfile · delete · dir · exist · fileattrib · fileparts · filesep · fullfile · genpath · getenv · getpref · isenv · isfile · isfolder · ispref · ls · matlabroot · memmapfile · memmapfile.subsasgn · memmapfile.subsref · mkdir · movefile · open · opentoline · path · pathsep · pcode · pwd · readstruct · rehash · restoredefaultpath · rmdir · rmpath · run · savepath · setenv · setpref · system · tempdir · tempname · uigetdir · uigetfile · unsetenv · userpath · what · winqueryreg · xmlread · xmlwrite
Tabular
arrayDatastore · csvread · csvwrite · detectImportOptions · dlmread · dlmwrite · fileDatastore · getvaropts · parquetDatastore · parquetinfo · parquetread · readcell · readmatrix · readtable · readtimetable · setvaropts · setvartype · spreadsheetImportOptions · writecell · writematrix · writetable · writetimetable · xlsread · xlswrite
Data
commit · data.copy · data.create · data.delete · data.exists · data.export · data.import · data.inspect · data.list · data.move · data.open · DataArray.chunk_shape · DataArray.codec · DataArray.dtype · DataArray.fill · DataArray.name · DataArray.rank · DataArray.read · DataArray.resize · DataArray.shape · DataArray.write · Dataset.array · Dataset.arrays · Dataset.attrs · Dataset.begin · Dataset.get_attr · Dataset.has_array · Dataset.id · Dataset.path · Dataset.refresh · Dataset.set_attr · Dataset.set_attrs · Dataset.snapshot · Dataset.version · DataTransaction.abort · DataTransaction.commit · DataTransaction.create_array · DataTransaction.delete_array · DataTransaction.fill · DataTransaction.id · DataTransaction.resize · DataTransaction.set_attr · DataTransaction.set_attrs · DataTransaction.status · DataTransaction.write
Filetext
fclose · feof · fgetl · fgets · fileread · filewrite · fopen · fprintf · fread · frewind · fwrite · readlines · writelines
Import
Json
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.