setappdata
Stores user specified application data in an object.
Syntax
setappdata(handle, dataname, datavalue)
Inputs
- handle
- Handle of the object associated with the data dataname. The application data are stored in a structure.
- dataname
- Name of the data to set.
- datavalue
- Value of the data.
Examples
setappdata is used to set user specified data to any object:
f = figure;
subplot(1, 2, 2);
lh = plot(1:10);
ph = uipanel('position',[0.02 0.1 0.4 0.4],'units','normalized');
bh = uicontrol(ph,'string', 'Text','position',[0.1 0.2 0.5 0.1],'units','normalized');
setappdata(f, 'data1', 1)
setappdata(lh, 'data1', 2)
setappdata(ph, 'data1', 3)
setappdata(bh, 'data1', 4)
Each object may have multiple entries in the application data structure:
f = figure;
setappdata(f, 'data1', 1)
setappdata(f, 'data2', [1:10])