isappdata - Determine if application data exists - MATLAB (original) (raw)
Main Content
Determine if application data exists
Syntax
Description
tf = isappdata([obj](#mw%5F35a0b2ce-a180-4271-8040-c73b66440179),[name](#mw%5Fb5945f9c-7f3b-4035-b48a-ad26ea829795))
determines whether the specified application data exists. The function returns1
(true
) if these conditions are met:
- The application data has the specified
name
value. - The application data is associated with the UI component
obj
.
Otherwise, isappdata
returns 0
(false
). The return result tf
is of data typelogical
.
Examples
Create a figure window. Then, get the current time by using the date
function.
Store the contents of d
by using the setappdata
function. In this case, store d
in the figure using the name identifier 'todaysdate'
.
setappdata(f,'todaysdate',d);
Confirm that d
is stored in the figure object under the specified name identifier.
isappdata(f,'todaysdate')
Use application data to determine the value to assign to a variable.
Create a figure window and specify val
. Store the contents of val
in the figure object using the name identifier 'primary'
.
f = figure; val = {'Red','Yellow','Blue'};
setappdata(f,'primary',val);
Set the variable colors
to a value that depends on the presence of application data by using conditional statements.
If there exists data associated with the name identifier 'primary'
in the figure, assign this data to colors
. Otherwise, assign new data to colors
. Print the value of colors
.
if isappdata(f,'primary') colors = getappdata(f,'primary') else colors = {'Orange','Green','Purple'} end
colors = 1×3 cell {'Red'} {'Yellow'} {'Blue'}
Input Arguments
Graphics object storing the data, specified as any graphics object. This object is the same graphics object passed to setappdata
during the storage operation.
Name identifier of the data, specified as a character vector or string scalar. This identifier is the same name identifier passed to setappdata
during the storage operation.
Version History
Introduced before R2006a