getappdata - Retrieve application data - MATLAB (original) (raw)
Main Content
Retrieve application data
Syntax
Description
Use this function to retrieve data stored using the setappdata function. Both of these functions provide a convenient way to share data between callbacks or between separate UIs.
[val](#f42-13763-val) = getappdata([obj](#mw%5F6c06294d-cc7f-4c3a-9e63-45e296612568),[name](#mw%5Fc54cf41c-eefe-4f22-a6b9-8c1494edd2ee))
returns a value stored in the graphics object, obj
. The name identifier, name
, uniquely identifies the value to retrieve.
[vals](#f42-13763-vals) = getappdata([obj](#mw%5F6c06294d-cc7f-4c3a-9e63-45e296612568))
returns all values stored in the graphics object with their name identifiers.
Examples
Create a figure window.
Get the current date and time as separate variables.
dt = fix(clock); currdate = dt(1:3); currtime = dt(4:6);
Store currdate
and currtime
using the setappdata
function.
setappdata(f,'todaysdate',currdate); setappdata(f,'presenttime',currtime);
Retrieve the date information.
getappdata(f,'todaysdate')
Retrieve all data associated with figure f
.
ans =
todaysdate: [2014 12 23]
presenttime: [16 51 5]
Input Arguments
Graphics object containing the value, specified as any graphics object. This is the same graphics object passed to setappdata
during the storage operation.
Name identifier, specified as a character vector or string scalar. This is the same name identifier passed to setappdata
during the storage operation.
Output Arguments
Stored value, returned as the same value and data type that was originally stored.
All values stored in the graphics object with name identifiers, returned as a structure. Each field in the structure corresponds to a stored value. The field names of the structure correspond to the name identifiers assigned when each value was stored.
Version History
Introduced before R2006a