function MainGUI
handles.GuiH = figure('Name', 'Main', 'Tag', 'myMainGUI');
uicontrol('Style', 'PushButton', 'Position', [10, 10, 100, 25], ...
'String', 'Start SubGUI', 'Callback', @StartSubGUI);
handles.TextH = uicontrol('Style', 'Text', 'Position', [10, 50, 100, 25]);
guidata(handles.GuiH, handles);
end
function StartSubGUI(ButtonH, EventData)
handles = guidata(ButtonH);
handles2.SubGuiH = figure('Name', 'SubGUI');
handles2.MainGuiH = handles.GuiH;
handles2.MainTextH = handles.TextH;
handles2.TextH = uicontrol('Style', 'Text', 'Position', [10, 50, 100, 25], ...
'Callback', @SubTextCB);
guidata(handles2.SugGuiH, handles2);
end
function SubTextH(TextH, EventData)
handles2 = guidata(TextH);
set(handels2.MainTextH, 'String', get(TextH, 'String'));
handles = guidata(handles2.MainGuiH);
handles.TextFromSub = get(TextH, 'String');
guidata(handles2.MainGuiH, handles);
end
Best Answer