MATLAB: Updating application data from several GUI’s

appdatacell arraygcfgetappdatagudieguisetappdatastoring data

Hello
I have a problem in storing appdata to already stored appdata.
I have two GUIs at the moment, this number will increase to one main GUI and several subGUIs.
well back to the problem; in my mainGui i create and store a cell array within the root
setappdata(0, 'hMainGui', gcf);
where the cell array has been stored within the current figure, both actions are made within the mainGuis openingfcn.
Now in the subGui I call the appdata
hMainGui = getappdata(0 , 'hMainGui');
cellArray = getappdata(hMainGui, 'cellArray');
I make a lot of processing of the cellArray after this, where every change in the cellArray is stored within hMainGui
setappdata(hMainGui, 'cellArray', cellArray);
now to the problem part; when this subGui is finished the updated information needs to be stored, such that other gui are able to obtain this information. what I have done so fare, and what isn't working is to set the hMainGui in the root directory again
setappdata(0, 'hMainGui', hMainGui);
My thoughts where that this would update the hMainGui stored in the root directory, but it doesn't. the information stored in the cellArray has not been updated when I call the information later in the process.
any suggestions?
more code can be added if need be.
kind regards
Steffan

Best Answer

Why not just store all needed information in the root?
setappdate(0,'cellarray',cellarray);
then from anywhere else:
cellarray = getappdata(0,'cellarray');
If you need to also store the handle for your GUIs, simply store them in the root also...
setappdata(0,'H_Main_GUI',H_Main_GUI) % GCBF from within Main GUI
You can store as many items as you need in the root's application data. Then these can all be reached from any other GUI.