I have two guis and when i call gui2 from gui1 using a continue button, gui2 does not work. However, gui2 works on its own when opened using guide. I have included the code below, please help!

조회 수: 1 (최근 30일)
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% get the handle of Gui1
h = findobj('Tag','Gui1');
% if exists (not empty)
if ~isempty(h)
% get handles and other user-defined data associated to Gui1
g1data = guidata(h);
% maybe you want to set the text in Gui2 with that from Gui1
set(handles.text1,'String',get(g1data.edit1,'String'));
end
open page1.fig
close(Opening_Page)
  댓글 수: 4
Preethi Thomas
Preethi Thomas 2016년 3월 14일
B.k, We tried the method you suggested, but it only opens the .m file and not the gui. What would you suggest we do for that?
Preethi Thomas
Preethi Thomas 2016년 3월 14일
@Geoff, If we can only use a .m file to launch a GUI, then what can we do in order to move from one gui to another using only the pushbutton?

댓글을 달려면 로그인하십시오.

채택된 답변

Geoff Hayes
Geoff Hayes 2016년 3월 14일
Preethi - as B.k. indicated, don't use open. Instead do the following
function pushbutton5_Callback(hObject, eventdata, handles)
% launch the new GUI
page1;
% close the existing GUI
close(handles.figure1);
In the above, I am assuming that page1 is the name of the other GUI that you want to open. I'm also assuming that figure1 is the tag for your current GUI (the one that you want to close). See http://www.mathworks.com/matlabcentral/answers/271560-have-a-pop-up-dialog-which-has-license-agreement which does something similar.
  댓글 수: 8
Preethi Thomas
Preethi Thomas 2016년 3월 17일
Geoff, I have changed the tags now, but am now getting this error.
Attempt to reference field of non-structure array.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by