MATLAB: Prevent main GUI from “refreshing” when passing data to it from a subgui.

guidata subgui handles

I currently have two GUIs which need to share data: a main GUI and subgui. Specifically, I need to update the handles structure of my main GUI from within the subgui.
My current method is to call the main GUI from within my subgui and then use guidata to obtain and update its handles. So, my code within one of the subgui callbacks looks something like this:
mainGuiHandle = mainGui;
mainGuiData = guidata(mainGuiHandle);
mainGuiData.some_data = some_data;
guidata(mainGui,mainGuiData)
I managed to prevent the main GUI's opening function from running by setting an "initialized" flag to be stored in the handles structure. However, the main GUI is still "brought to front" whenever it is called. I've partially counteracted this by using the uistack function. There still remains a brief flickering, however, which is a bit of an annoyance. My question then, is how to prevent this, and whether it can be done using my current method or if it requires another strategy. I suspect I need to go about this differently, as the current method is fairly crude.
Apologies this question has already been asked or if the answer is readily available in Matlab documentation–I did a bit of snooping around but was unable to find anything relevant to my situation.
Note: after looking around a bit, I chose this method because I have little experience with having two GUIs "interact" and it seemed both the simplest and most intuitive. I looked into other methods such as using setappdata, but decided against them. It may very well be that, for what I'm wanting to accomplish, this method isn't ideal, so I'm open to "starting fresh". You'll likely just have to endure some painfully basic questions. ^_^

Best Answer

I solved this by passing in the handles structure of the main GUI that also contained the main GUI figure handle, adding it as a branch to the subgui handle structure, and then updating the main figure handle from within the subgui using guidata().
New code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%MAIN GUI opening function %%%%
function MainGui_OpeningFcn(hObject,~,handles,varargin)
handles.main = gcf;
guidata(hObject,handles)
%%%%Some callback within MAIN GUI %%%%
function CallSubGui_Callback(hObject, ~, handles)
subgui(handles)
guidata(hObject,handles)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%SUBGUI opening function %%%%
function SubGui_OpeningFcn(hObject,~,handles,varargin)
handles.mainGuiHandles = varargin(1);
guidata(hObject,handles)
%%%%Some callback within SUB GUI %%%%
function ChangeData_Callback(hObject,~,handles,varargin)
some_data = rand(5);
handles.mainGuiHandles.some_data = some_data;
guidata(handles.mainGuiHandles.main,handles.mainGuiHandles)
Related Question