- •Is constrained to the grid of size stepsize starting at the
- •If a mouse button is not down.
- •If Fixed is used for HorizontalAlignment or VerticalAlignment, then
- •It sets the figure properties that are recommended for dialog boxes.
- •In the base directory.
- •If isequal(filename,0) || isequal(pathname,0)
- •Itself, or any object contained in the figure.
- •Itself, or any object contained in the figure.
- •Instring is a cell array. Paragraph breaks are implemented for
- •Values. See the reference guide for detailed property information.
- •Information.
- •Information.
- •Information.
In the base directory.
Windows:
Base directory is the Windows Desktop directory.
UNIX:
Base directory is the directory from which MATLAB is started.
The dialog box displays all filetypes by default. The type
of files that are displayed can be changed by changing the filter
string in the Selected Directory field of the dialog box. If the
user selects a file instead of a directory, then the directory
containing the file is returned.
Parameter TITLE is a string containing a title for the dialog box.
When TITLE is empty, a default title is assigned to the dialog box.
Windows:
The TITLE string replaces the default caption inside the
dialog box for specifying instructions to the user.
UNIX:
The TITLE string replaces the default title of the dialog box.
When no input parameters are specified, the dialog box opens in the
current directory with the default dialog title.
The output parameter DIRECTORYNAME is a string containing the
directory selected in the dialog box. If the user presses the Cancel
button it is set to 0.
Examples:
directoryname = uigetdir;
Windows:
directoryname = uigetdir('D:\APPLICATIONS\MATLAB');
directoryname = uigetdir('D:\APPLICATIONS\MATLAB', 'Pick a Directory');
UNIX:
directoryname = uigetdir('/home/matlab/work');
directoryname = uigetdir('/home/matlab/work', 'Pick a Directory');
See also uigetfile, uiputfile.
Reference page in Help browser
doc uigetdir
<uigetfile> - Standard open file dialog box.
UIGETFILE Standard open file dialog box.
[FILENAME, PATHNAME, FILTERINDEX] = UIGETFILE(FILTERSPEC, TITLE)
displays a dialog box for the user to fill in, and returns the filename
and path strings and the index of the selected filter. A successful
return occurs only if the file exists. If the user selects a file
that does not exist, an error message is displayed, and control
returns to the dialog box. The user may then enter another filename,
or press the Cancel button.
The FILTERSPEC parameter determines the initial display of files in
the dialog box. For example '*.m' lists all MATLAB code files. If
FILTERSPEC is a cell array, the first column is used as the list of
extensions, and the second column is used as the list of descriptions.
When FILTERSPEC is a string or a cell array, "All files" is appended
to the list.
When FILTERSPEC is empty the default list of file types is used.
Parameter TITLE is a string containing the title of the dialog box.
The output variable FILENAME is a string containing the name of the
file selected in the dialog box. If the user presses Cancel, it is set
to 0.
The output variable PATHNAME is a string containing the path of the
file selected in the dialog box. If the user presses Cancel, it is set
to 0.
The output variable FILTERINDEX returns the index of the filter
selected in the dialog box. The indexing starts at 1. If the user
presses Cancel, it is set to 0.
[FILENAME, PATHNAME, FILTERINDEX] = UIGETFILE(FILTERSPEC, TITLE, FILE)
FILE is a string containing the name to use as the default selection.
[FILENAME, PATHNAME] = UIGETFILE(..., 'MultiSelect', SELECTMODE)
specifies if multiple file selection is enabled for the UIGETFILE
dialog. Valid values for SELECTMODE are 'on' and 'off'. If the value of
'MultiSelect' is set to 'on', the dialog box supports multiple file
selection. 'MultiSelect' is set to 'off' by default.
The output variable FILENAME is a cell array of strings if multiple
filenames are selected. Otherwise, it is a string representing
the selected filename.
[FILENAME, PATHNAME] = UIGETFILE(..., 'Location', [X Y]) places the
dialog box at screen position [X,Y] in pixel units. This option is
supported on UNIX platforms only.
NOTE: THIS SYNTAX IS OBSOLETE AND WILL BE IGNORED
[FILENAME, PATHNAME] = UIGETFILE(..., X, Y) places the dialog box at
screen position [X,Y] in pixel units. This option is supported on UNIX
platforms only.
NOTE: THIS SYNTAX IS OBSOLETE AND WILL BE IGNORED.
Examples:
[filename, pathname, filterindex] = uigetfile('*.m', 'Pick a MATLAB code file');
[filename, pathname, filterindex] = uigetfile( ...
{'*.m;*.fig;*.mat;*.mdl', 'All MATLAB Files (*.m, *.fig, *.mat, *.mdl)';
'*.m', 'MATLAB Code (*.m)'; ...
'*.fig','Figures (*.fig)'; ...
'*.mat','MAT-files (*.mat)'; ...
'*.mdl','Models (*.mdl)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick a file');
[filename, pathname, filterindex] = uigetfile( ...
{'*.mat','MAT-files (*.mat)'; ...
'*.mdl','Models (*.mdl)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick a file', 'Untitled.mat');
Note, multiple extensions with no descriptions must be separated by semi-
colons.
[filename, pathname] = uigetfile( ...
{'*.m';'*.mdl';'*.mat';'*.*'}, ...
'Pick a file');
Associating multiple extensions with one description:
[filename, pathname] = uigetfile( ...
{'*.m;*.fig;*.mat;*.mdl', 'All MATLAB Files (*.m, *.fig, *.mat, *.mdl)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick a file');
Enabling multiple file selection in the dialog:
[filename, pathname, filterindex] = uigetfile( ...
{'*.mat','MAT-files (*.mat)'; ...
'*.mdl','Models (*.mdl)'; ...
'*.*', 'All Files (*.*)'}, ...
'Pick a file', ...
'MultiSelect', 'on');
This code checks if the user pressed cancel on the dialog.
[filename, pathname] = uigetfile('*.m', 'Pick a MATLAB code file');
if isequal(filename,0) || isequal(pathname,0)
disp('User pressed cancel')
else
disp(['User selected ', fullfile(pathname, filename)])
end
See also uigetdir, uiputfile.
Reference page in Help browser
doc uigetfile
<uigetpref> - question dialog box with preference support
UIGETPREF question dialog box with preference support
VALUE=UIGETPREF(GROUP, PREF, TITLE, QUESTION, PREF_CHOICES)
Returns one of the strings in PREF_CHOICES, either by prompting the user with
a multiple-choice question dialog box, or by returning a previous answer
stored in the preferences database. By default, the dialog box is shown each
time, with each choice on a different pushbutton, and with a checkbox controlling
whether the returned value should be stored in preferences and automatically reused
in subsequent invocations. When the user clicks the checkbox before choosing one
of the pushbuttons, the pushbutton choice is stored in preferences and returned.
Subsequent calls to UIGETPREF detect that the last choice was stored in preferences,
and return that choice immediately without displaying the dialog. If the user does
not click the checkbox before choosing a pushbutton, a special value is stored in
preferences which indicates that subsequent calls to UIGETPREF should display
the dialog box.
GROUP and PREF define the preference. If the preference does not already exist,
UIGETPREF creates it.
TITLE defines the string displayed in the dialog's titlebar.
QUESTION is a descriptive paragraph displayed in the dialog, specified as a string
array or cell array of strings. This should contain the question the user is being
asked, and should be detailed enough to give the user a clear understanding of their
choice and its impact. UIGETPREF inserts line breaks between rows of the string array,
between elements of the cell array of strings, or between '|' or newline characters in the
string vector.
PREF_CHOICES is either a string, cell array of strings, or '|'-separated string
specifying the strings to be displayed on the pushbuttons. Each string element is
displayed in a separate pushbutton. The string on the selected pushbutton is returned.
If the checkbox has been clicked, that string is also stored in preferences. If the
checkbox has not been clicked, a special value is stored in preferences.
PREF_CHOICES may also be an 2xN cell array of strings, if the internal preference
values should be different than the strings displayed on the pushbuttons. The first
row should contain the preference strings, and the second row should contain the
related pushbutton strings. Note that the preference values are still returned in VALUE,
not the button labels.
[VAL,DLGSHOWN] = UIGETPREF(...) will return whether or not the dialog was shown.
Additional arguments may be passed in as parameter-value pairs:
(...'CheckboxState',0 or 1) sets the initial state of the checkbox,
either checked or unchecked. By default it is not checked.
(...'CheckboxString',CBSTR) sets the string on the checkbox. By default
it is 'Never show this dialog again'
(...'HelpString',HSTR) sets the string on the help button. By default the string
is empty and there is no help button.
(...'HelpFcn',HFCN) sets the callback that is executed when the help button is
pressed. By default it is doc('uigetpref'). Note that if
there is no 'HelpString', a button will not be created.
(...'ExtraOptions',EO) creates extra buttons which are not mapped to any preference
settings. Can be a string or a cell array of strings. By
default it is {} and no extra buttons are created.
(...'DefaultButton',DB) sets the button value that is returned if the dialog is closed.
By default, it is the first button. Note that DB does not have
to correspond to a preference or ExtraOption.
Example:
[selectedButton,dlgShown]=uigetpref('graphics','savefigurebeforeclosing',...
'Closing Figure',...
{'Do you want to save your figure before closing?'
''
'You can save your figure manually by typing ''hgsave(gcf)'''},...
{'always','never';'Yes','No'},...
'ExtraOptions','Cancel',...
'DefaultButton','Cancel',...
'HelpString','Help',...
'HelpFcn','doc(''closereq'');')
See also uisetpref, getpref, setpref, addpref, rmpref
Reference page in Help browser
doc uigetpref
<uiputfile> - Standard save file dialog box.
UIPUTFILE Standard save file dialog box.
[FILENAME, PATHNAME, FILTERINDEX] = UIPUTFILE(FILTERSPEC, TITLE)
displays a dialog box for the user to fill in and returns the
filename and path strings and the index of the selected filter.
A successful return occurs if a valid filename is specified. If an
existing filename is specified or selected, a warning message is
displayed. The user may select Yes to use the filename or No to
return to the dialog to select another filename.
The FILTERSPEC parameter determines the initial display of files in
the dialog box. For example '*.m' lists all the MATLAB code files. If
FILTERSPEC is a cell array, the first column is used as the list of
extensions, and the second column is used as the list of descriptions.
When FILTERSPEC is a string or a cell array, "All files" is appended
to the list.
When FILTERSPEC is empty the default list of file types is used.
When FILTERSPEC is a filename, it is used as the default filename and
the file's extension is used as the default filter.
Parameter TITLE is a string containing the title of the dialog
box.
The output variable FILENAME is a string containing the name of the file
selected in the dialog box. If the user presses Cancel, it is set to 0.
The output variable PATH is a string containing the name of the path
selected in the dialog box. If the user presses Cancel, it is set to 0.
The output variable FILTERINDEX returns the index of the filter selected
in the dialog box. The indexing starts at 1. If the user presses Cancel,
it is set to 0.
[FILENAME, PATHNAME, FILTERINDEX] = UIPUTFILE(FILTERSPEC, TITLE, FILE)
FILE is a string containing the name to use as the default selection.
[FILENAME, PATHNAME] = UIPUTFILE(..., 'Location', [X Y])
places the dialog box at screen position [X,Y] in pixel units.
This option is supported on UNIX platforms only.
NOTE: THIS SYNTAX IS OBSOLETE AND WILL BE IGNORED.
[FILENAME, PATHNAME] = UIPUTFILE(..., X, Y)
places the dialog box at screen position [X,Y] in pixel units.
This option is supported on UNIX platforms only.
NOTE: THIS SYNTAX IS OBSOLETE AND WILL BE IGNORED.
Examples:
[filename, pathname] = uiputfile('matlab.mat', 'Save Workspace as');
[filename, pathname] = uiputfile('*.mat', 'Save Workspace as');
[filename, pathname, filterindex] = uiputfile( ...
{'*.m;*.fig;*.mat;*.mdl', 'All MATLAB Files (*.m, *.fig, *.mat, *.mdl)';
'*.m', 'MATLAB Code (*.m)'; ...
'*.fig','Figures (*.fig)'; ...
'*.mat','MAT-files (*.mat)'; ...
'*.mdl','Models (*.mdl)'; ...
'*.*', 'All Files (*.*)'}, ...
'Save as');
[filename, pathname, filterindex] = uiputfile( ...
{'*.mat','MAT-files (*.mat)'; ...
'*.mdl','Models (*.mdl)'; ...
'*.*', 'All Files (*.*)'}, ...
'Save as', 'Untitled.mat');
Note, multiple extensions with no descriptions must be separated by semi-
colons.
[filename, pathname] = uiputfile( ...
{'*.m';'*.mdl';'*.mat';'*.*'}, ...
'Save as');
Associate multiple extensions with one description like this:
[filename, pathname] = uiputfile( ...
{'*.m;*.fig;*.mat;*.mdl', 'All MATLAB Files (*.m, *.fig, *.mat, *.mdl)'; ...
'*.*', 'All Files (*.*)'}, ...
'Save as');
This code checks if the user pressed cancel on the dialog.
[filename, pathname] = uiputfile('*.m', 'Pick an MATLAB code file');