%% Conditional Assignment Using App Data
% 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

% Copyright 2020 The MathWorks, Inc.