This question is closed. Reopen it to edit or answer.

Can I use setappdata /getappdata to store data in a "panel" as the parent of uicontrol? Doesnt seem to work...

1 view (last 30 days)
It seems setappdata will not store data in a panel - I had to store the data in the figure holding the panel. I have some uicontrols with a panel as their parent, and a figure is the parent of the panel. The getappdata didnt work in the uicallback:
getappdata(src.Parent,'DataName') % < this didnt work - points at panel
What did work in the uicontrol callback is:
getappdata(src.Parent.Parent,'DataName') % < this worked, points at figure
src.Parent.Parent breaks down as:
src = the uicontrol (a checkbox)
src.Parent = the panel containing the uicontrol
src.Parent.Parent = the figure containing the panel
What am I not understanding?
Thanks in advance.

Answers (1)

Div Tiwari
Div Tiwari on 9 Aug 2016
Could you clarify what you mean by it not working? Was there an error message or was the data simply not stored? The 'setappdata' function supports 'uipanel' objects and it works just fine for me.
Please also try executing the example code in the 'uipanel' documentation page ( ) and using 'setappdata' with the panel. For example, for the first example, try:
>> setappdata(hp, 'DataName', 10);
>> getappdata(hp, 'DataName')
ans =

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!