Main Content


Determine if application data exists



    tf = isappdata(obj,name) checks for application data and returns 1 (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 type logical.


    collapse all

    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'.

    f = figure;
    d = date
    d = 

    Confirm that d is stored in the figure object under the specified name identifier.

    ans = logical

    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'};

    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')
        colors = {'Orange','Green','Purple'}
    colors = 1x3 cell
        {'Red'}    {'Yellow'}    {'Blue'}

    Input Arguments

    collapse all

    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