MATLAB: Several Guis Sharing information

sevearl guis share information

I am making a program with several GUIS. Basically it´s a first GUI for input data, and them few Guis that are open depending of the input option. I am trying with a first simple sample of 2 Guis, and I am using… b=str2double(get(handles.edit1,'String')); setappdata(0,'R',b); secondgui; … in the first gui, and… a=getappdata(0,'R') set(handles.text2,'String',a) … in the second gui
This way it works, but I don´t understand why this "0" and don´t know what other labels can I use apart from 0.
I am interested in all possible suggestions Thank you very much.

Best Answer

  • 0 is the root matlab handle. Thus you are setting a field 'R' to this MATLAB's instance that can be retrieved from anything in this instance. You could also set it to the handle of a figure so that the figure has a new field (or property), 'R', that can be accessed by anything that has access to that handle. This does mean that if the figure is closed, the info is gone.
    Hope this helps.