- •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.
If isequal(filename,0) || isequal(pathname,0)
disp('User pressed cancel')
else
disp(['User selected ', fullfile(pathname, filename)])
end
See also uigetdir, uigetfile.
Reference page in Help browser
doc uiputfile
<uiopen> - Present file selection dialog with appropriate file filters.
UIOPEN Present file selection dialog with appropriate file filters.
UIOPEN presents a file selection dialog. The user can either choose a
file to open or click cancel. No further action is taken if the user
clicks on cancel. Otherwise the OPEN command is evaluated in the base
workspace with the user specified filename.
These are the file filters presented using UIOPEN.
1st input argument Filter List
<no input args> *.m, *.fig, *.mat,
*.mdl (if Simulink is installed),
*.cdr (if Stateflow is installed),
*.rtw, *.tmf, *.tlc, *.c, *.h, *.ads, *.adb
(if Real-Time Workshop is installed),
*.*
MATLAB *.m, *.fig, *.*
LOAD *.mat, *.*
FIGURE *.fig, *.*
SIMULINK *.mdl, *.*
EDITOR *.m, *.mdl, *.cdr, *.rtw, *.tmf, *.tlc, *.c, *.h, *.ads, *.adb, *.*
If the first input argument is unrecognized, it is treated as a file
filter and passed directly to the UIGETFILE command.
If the second input argument is true, the first input argument is
treated as a filename.
Examples:
uiopen % displays the dialog with the file filter set to all MATLAB
%files.
uiopen('matlab') %displays the dialog with the file
%filter set to all MATLAB files.
uiopen('load') %displays the dialog with the file filter set to
%MAT-files (*.mat).
uiopen('figure') %displays the dialog with the file filter set to
%figure files (*.fig).
uiopen('simulink') %displays the dialog with the file filter set to
%model files (*.mdl).
uiopen('editor') %displays the dialog with the file filter set to
%all MATLAB files except for MAT-files and FIG-files.
%All files are opened in the MATLAB Editor.
See also uigetfile, uiputfile, open, uiimport.
Reference page in Help browser
doc uiopen
<uisave> - GUI Helper function for SAVE
UISAVE GUI Helper function for SAVE
UISAVE with no args prompts for file name then saves all variables from
workspace.
UISAVE(VARIABLES) prompts for file name then saves variables listed in
VARIABLES, which may be a string or cell array of strings.
UISAVE(VARIABLES, FILENAME) uses the specified file name as the default
instead of "matlab.mat".
Examples:
Example 1:
h = 5;
uisave('h');
Example 2:
h = 365;
uisave('h', 'var1');
See also save, load
Reference page in Help browser
doc uisave
<uisetcolor> - Color selection dialog box.
UISETCOLOR Color selection dialog box.
C = UISETCOLOR displays a color selection dialog appropriate to
the platform, and returns the color selected by the
user. The dialog is initialized to white.
C = UISETCOLOR([R G B]) displays a dialog initialized to the
specified color, and returns the color selected by the user.
R, G, and B must be values between 0 and 1.
C = UISETCOLOR(H) displays a dialog initialized to the color of
the object specified by handle H, returns the color selected by
the user, and applies it to the object. H must be the handle
to an object containing a color property.
C = UISETCOLOR(...,'dialogTitle') displays a dialog with the
specified title.
If the user presses Cancel from the dialog box, or if any error
occurs, the output value is set to the input RGB triple, if provided;
otherwise, it is set to 0.
Example:
hText = text(.5,.5,'Hello World');
C = uisetcolor(hText, 'Set Text Color')
See also inspect, propedit, uisetfont.
Reference page in Help browser
doc uisetcolor
<uisetfont> - Font selection dialog box.
UISETFONT Font selection dialog box.
S = UISETFONT(FIN, 'dialogTitle') displays a dialog box for the
user to fill in, and applies the selected font to the input
graphics object.
All the parameters are optional.
If parameter FIN is used, it must either specify a handle to a
font related text, uicontrol, axes object, or it must be a
font structure.
If FIN is a handle to an object, the font properties currently
assigned to this object are used to initialize the font dialog box.
If FIN is a structure, its fields must be some subset of
FontName, FontUnits, FontSize, FontWeight, or FontAngle, and must
have values appropriate for any object with font properties.
If parameter 'dialogTitle' is used, it is a string containing the
title of the dialog box.
The output S is a structure. The structure S is returned with the
font property names as fields. The fields are FontName,
FontUnits, FontSize, FontWeight, and FontAngle.
If the user presses Cancel from the dialog box, or if any error
occurs, the output value is set to 0.
Example:
Text1 = uicontrol('style','text','string','XxYyZz');
Text2 = uicontrol('style','text','string','AxBbCc',...
'position', [200 20 60 20]);
s = uisetfont(Text1, 'Update Font');
if isstruct(s) % Check for cancel
set(Text2, s);
end
See also inspect, listfonts, propedit, uisetfont.
Reference page in Help browser
doc uisetfont
<waitbar> - Display wait bar.
WAITBAR Display wait bar.
H = WAITBAR(X,'message', property, value, property, value, ...)
creates and displays a waitbar of fractional length X. The
handle to the waitbar figure is returned in H.
X should be between 0 and 1. Optional arguments property and
value allow to set corresponding waitbar figure properties.
Property can also be an action keyword 'CreateCancelBtn', in
which case a cancel button will be added to the figure, and
the passed value string will be executed upon clicking on the
cancel button or the close figure button.
WAITBAR(X) will set the length of the bar in the most recently
created waitbar window to the fractional length X.
WAITBAR(X,H) will set the length of the bar in waitbar H
to the fractional length X.
WAITBAR(X,H,'message') will update the message text in
the waitbar figure, in addition to setting the fractional
length to X.
WAITBAR is typically used inside a FOR loop that performs a
lengthy computation.
Example:
h = waitbar(0,'Please wait...');
for i=1:1000,
% computation here %
waitbar(i/1000,h)
end
See also dialog, msgbox.
Reference page in Help browser
doc waitbar
<warndlg> - Warning dialog box.
WARNDLG Warning dialog box.
HANDLE = WARNDLG(WARNSTRING,DLGNAME) creates an warning dialog box
which displays WARNSTRING in a window named DLGNAME. A pushbutton
labeled OK must be pressed to make the warning box disappear.
HANDLE = WARNDLG(WARNSTRING,DLGNAME,CREATEMODE) allows CREATEMODE options
that are the same as those offered by MSGBOX. The default value
for CREATEMODE is 'non-modal'.
WarnString will accept any valid string input but a cell
array is preferred.
WARNDLG uses MSGBOX. Please see the help for MSGBOX for a
full description of the input arguments to WARNDLG.
Examples:
f = warndlg('This is an warning string.', 'My Warn Dialog');
f = warndlg('This is an warning string.', 'My Warn Dialog', 'modal');
See also dialog, errordlg, helpdlg, inputdlg, listdlg, msgbox,
questdlg.
Reference page in Help browser
doc warndlg
Preferences
<addpref> - Add preference.
ADDPREF Add preference.
ADDPREF('GROUP','PREF',VAL) creates the preference specified by
GROUP and PREF and sets its value to VAL. It is an error to add a
preference that already exists.
GROUP labels a related collection of preferences. You can choose
any name that is a legal variable name, and is descriptive enough
to be unique, e.g. 'MathWorks_GUIDE_ApplicationPrefs'.
PREF identifies an individual preference in that group, and
must be a legal variable name.
ADDPREF('GROUP',{'PREF1','PREF2',...'PREFn'},{VAL1,VAL2,...VALn})
creates the preferences specified by the cell array of names,
setting each to the corresponding value.
Preference values are persistent and maintain their values between
MATLAB sessions. Where they are stored is system dependent.
Example:
addpref('mytoolbox','version',1.0)
See also getpref, setpref, rmpref, ispref.
Overloaded methods:
mbcprefs/addpref
Reference page in Help browser
doc addpref
<getpref> - Get preference.
GETPREF Get preference.
GETPREF('GROUP','PREF') returns the value for the preference
specified by GROUP and PREF. It is an error to get a preference
that does not exist.
GROUP labels a related collection of preferences. You can choose
any name that is a legal variable name, and is descriptive enough
to be unique, e.g. 'MathWorks_GUIDE_ApplicationPrefs'.
PREF identifies an individual preference in that group, and
must be a legal variable name.
GETPREF('GROUP','PREF',DEFAULT) returns the current value if the
preference specified by GROUP and PREF exists. Otherwise creates
the preference with the specified default value and returns that
value.
GETPREF('GROUP',{'PREF1','PREF2',...'PREFn'}) returns a cell array
containing the values for the preferences specified by GROUP and
the cell array of preferences. The return value is the same size as the
input cell array. It is an error if any of the preferences do not
exist.
GETPREF('GROUP',{'PREF1',...'PREFn'},{DEFAULT1,...DEFAULTn})
returns a cell array with the current values of the preferences
specified by GROUP and the cell array of preference names. Any
preference that does not exist is created with the specified
default value and returned.
GETPREF('GROUP') returns the names and values of all
preferences in the GROUP as a structure.
GETPREF returns all groups and preferences as a structure.
Preference values are persistent and maintain their values between
MATLAB sessions. Where they are stored is system dependent.
Example:
addpref('mytoolbox','version',1.0)
getpref('mytoolbox','version')
Example:
getpref('mytoolbox','version',1.0);
See also setpref, addpref, rmpref, ispref, uigetpref, uisetpref
Overloaded methods:
mbcprefs/getpref
Reference page in Help browser
doc getpref
<ispref> - Test for existence of preference.
ISPREF Test for existence of preference.
ISPREF('GROUP','PREF') returns 1 if the preference specified by
GROUP and PREF exists, and 0 otherwise.
ISPREF('GROUP') returns 1 if the GROUP exists, and 0 otherwise.
ISPREF('GROUP',{'PREF1','PREF2',...'PREFn'}) returns a logical
array the same length as the cell array of preference names,
containing 1 where each preference exists, and 0 elsewhere.
Example:
addpref('mytoolbox','version',1.0)
ispref('mytoolbox','version')
See also addpref, getpref, setpref, rmpref.
Overloaded methods:
mbcprefs/ispref
Reference page in Help browser
doc ispref
<rmpref> - Remove preference.
RMPREF Remove preference.
RMPREF('GROUP','PREF') removes the preference specified by GROUP
and PREF. It is an error to remove a preference that does not
exist.
RMPREF('GROUP',{'PREF1','PREF2',...'PREFn'}) removes each
preference specified in the cell array of names. It is an error
if any of the preferences do not exist.
RMPREF('GROUP') removes all the preferences for the specified
GROUP. It is an error to remove a group that does not exist.
Example:
addpref('mytoolbox','version',1.0)
rmpref('mytoolbox')
See also addpref, getpref, setpref, ispref.
Reference page in Help browser
doc rmpref
<setpref > - Set preference.
SETPREF Set preference.
SETPREF('GROUP','PREF',VAL) sets the preference specified by GROUP
and PREF to the value VAL. Setting a preference that does not yet
exist causes it to be created.
GROUP labels a related collection of preferences. You can choose
any name that is a legal variable name, and is descriptive enough
to be unique, e.g. 'MathWorks_GUIDE_ApplicationPrefs'.
PREF identifies an individual preference in that group, and
must be a legal variable name.
SETPREF('GROUP',{'PREF1','PREF2',...'PREFn'},{VAL1,VAL2,...VALn})
sets each preference specified in the cell array of names to the
corresponding value.
Preference values are persistent and maintain their values between
MATLAB sessions. Where they are stored is system dependent.
Example:
addpref('mytoolbox','version',0.0)
setpref('mytoolbox','version',1.0)
getpref('mytoolbox','version')
See also getpref, addpref, rmpref, ispref.
Overloaded methods:
mbcprefs/setpref
Reference page in Help browser
doc setpref
Miscellaneous utilities
<allchild> - Get all object children
ALLCHILD Get all object children
ChildList=ALLCHILD(HandleList) returns the list of all children
(including ones with hidden handles) for each handle. If
HandleList is a single element, the output is returned in a
vector. Otherwise, the output is a cell array.
Example:
get(gca,'children')
%or
allchild(gca)
See also get, findall.
Reference page in Help browser
doc allchild
<clipboard> - Copy and paste strings to and from system clipboard.
CLIPBOARD Copy and paste strings to and from system clipboard.
CLIPBOARD('copy', STUFF) Sets the clipboard contents to STUFF. If STUFF
is not a char array, MAT2STR is used to convert it to a string.
STR = CLIPBOARD('paste') Returns the current contents of the clipboard as
a string or '' if the current clipboard cannot be converted to a string.
DATA = CLIPBOARD('pastespecial') Returns the current contents of the
clipboard as an array using UIIMPORT.
Note: CLIPBOARD requires Java on all platforms.
Example:
clipboard('copy', 'this has been copied');
str = clipboard('paste');
data = clipboard('pastespecial');
See also load, fileformats, uiimport
Reference page in Help browser
doc clipboard
<findfigs> - Position figures on to screen.
FINDFIGS Position figures on to screen.
FINDFIGS will find all visible figures that are positioned
completely off-screen and make them visible on screen at the top
left corner of the screen.
Example:
fig = figure;
set(fig,'pos',[2000 2000 500 500]);
findfigs %This should bring figure window to the top left of screen
See also allchild, findall, findobj, gca, gcf
Reference page in Help browser
doc findfigs
<getpixelposition> - Get the position of an HG object in pixel units.
GETPIXELPOSITION Get the position of an HG object in pixel units.
GETPIXELPOSITION(HANDLE) gets the position of the object specified by
HANDLE in pixel units.
GETPIXELPOSITION(HANDLE, RECURSIVE) gets the position as above. If
RECURSIVE is true, the returned position is relative to the parent
figure of HANDLE.
POSITION = GETPIXELPOSITION(...) returns the pixel position in POSITION.
Example:
f = figure;
p = uipanel('Position', [.2 .2 .6 .6]);
h1 = uicontrol(p, 'Units', 'normalized', 'Position', [.1 .1 .5 .2]);
% Get pixel position w.r.t the parent uipanel
pos1 = getpixelposition(h1)
% Get pixel position w.r.t the parent figure using the recursive flag
pos2 = getpixelposition(h1, true)
See also setpixelposition, uicontrol, uipanel
Reference page in Help browser
doc getpixelposition
<listfonts> - Get list of available system fonts in cell array.
LISTFONTS Get list of available system fonts in cell array.
C = LISTFONTS returns list of available system fonts.
C = LISTFONTS(H) returns system fonts with object's FontName
sorted into the list.
Examples:
Example1:
list = listfonts
Example2:
h = uicontrol('Style', 'text', 'string', 'My Font');
list = listfonts(h)
See also uisetfont.
Reference page in Help browser
doc listfonts
<movegui> - Move a figure window to a specified position on the screen.
MOVEGUI Move a figure window to a specified position on the screen.
MOVEGUI(H, POSITION) moves the figure associated with handle H to
the specified POSITION on the screen, preserving its size.
H can be the handle to a figure, or to any object within a figure
The POSITION argument can be any one of the strings:
'north' - top center edge of screen
'south' - bottom center edge of screen
'east' - right center edge of screen
'west' - left center edge of screen
'northeast' - top right corner of screen
'northwest' - top left corner of screen
'southeast' - bottom right corner of screen
'southwest' - bottom left corner of screen
'center' - center of screen
'onscreen' - nearest onscreen location to current position (with an
additional inset of 30 pixels from the edge of the screen). If the
figure is bigger than the screen size, this moves the top-left corner
of the figure window onscreen.
The POSITION argument can also be a two-element vector [H V],
where depending on sign, H specifies the figure's offset from the
left or right edge of the screen, and V specifies the figure's
offset from the top or bottom of the screen, in pixels:
H (for h >= 0) offset of left side from left edge of screen
H (for h < 0) offset of right side from right edge of screen
V (for v >= 0) offset of bottom edge from bottom of screen
V (for v < 0) offset of top edge from top of screen
MOVEGUI(H) moves the figure associated with handle H 'onscreen'.
MOVEGUI(POSITION) moves the GCF or GCBF to the specified position.
MOVEGUI moves the GCF or GCBF 'onscreen' (useful as a string-based
CreateFcn callback for a saved figure, to ensure it will appear
onscreen when reloaded, regardless of its saved position)
MOVEGUI(H, <event data>)
MOVEGUI(H, <event data>, POSITION) when used as a function-handle
callback, moves the figure specified by H to the default position,
or to the specified position, safely ignoring the automatically
passed-in event data struct.
Example:
This example demonstrates MOVEGUIs usefulness as a means of ensuring
that a saved GUI will appear onscreen when reloaded, regardless of
differences between screen sizes and resolutions between the machines
on which it was saved and reloaded. It creates a figure off the
screen, assigns MOVEGUI as its CreateFcn callback, then saves and
reloads the figure:
f=figure('position', [10000, 10000, 400, 300]);
set(f, 'CreateFcn', 'movegui')
hgsave(f, 'onscreenfig')
close(f)
f2 = hgload('onscreenfig')
The following are a few variations on ways MOVEGUI can be assigned as
the CreateFcn, using both string and function-handle callbacks, with
and without extra arguments, to achieve a variety of behaviors:
set(gcf, 'CreateFcn', 'movegui center')
set(gcf, 'CreateFcn', @movegui)
set(gcf, 'CreateFcn', {@movegui, 'northeast'})
set(gcf, 'CreateFcn', {@movegui, [-100 -50]})
See also openfig, guihandles, guidata, guide.
Reference page in Help browser
doc movegui
<guidata> - Store or retrieve application data.
GUIDATA Store or retrieve application data.
GUIDATA(H, DATA) stores the specified data in the figure's
application data.
H is a handle that identifies the figure - it can be the figure