MATLAB Answers

0

I can not get a "GUIDE" to open

Pedro Guevara さんによって質問されました 2019 年 5 月 31 日
最新アクティビティ Pedro Guevara さんによって コメントされました 2019 年 6 月 2 日
Goodnight. I have the following problem. I have 2 "Guides", one called "form1" and the other "form2". The process is to press a button of the "form1" must make a series of calculations and at the end of all those calculations must open my "form2" (taking some data from my "form1"). I already tried several solcutions that I found on the internet, but I can not get my "form2" open, in fact I have not been able to create an .m file for that Guide. Please, I need your help with this. I am very new in Matlab and I still do not know much about this tool. thank you.

  0 件のコメント

サインイン to comment.

製品


リリース

R2017b

1 件の回答

Walter Roberson
回答者: Walter Roberson
2019 年 5 月 31 日
 採用された回答

Invoke guide and tell it to create new GUI, and give it the name form2 . Put all relevant controls in it. Save it as normal, with .fig and .m file.
Inside form1, you can use
handles.data_form2_will_need = whatever;
guidata(handles);
form2_h = form2();
to get the handle of form2 in order to communicate with it.
Inside the OpenFcn for form2 you can use,
%we are inside form2 here, handles refers only to form2's handles
handles.form1_h = findobj(groot, 'tag', 'form1');
handles1 = guidata(handles.form1_h); %this is form1's handles
handles.data_form2_needs = handles1.data_form2_will_need;
guidata(hObject, handles)

  3 件のコメント

Pedro Guevara 2019 年 5 月 31 日
Hi. First, thank you for your response. Pass the following. Test your code, but on the line:
guidata(handles);
The following error appears: Error in form1> MatricesK_Callback (line 272) guidata (handles)
then I remove that line, and it happens that the "form2" opens for a brief second and then closes, and this error appears in the form2.m:
Error in form2>form2_OpeningFcn (line 64)
handle1 = guidata (handle.form1_h); % esto es manejador de form1.
I suppose this error is due to remove the line "guidata (handles);" of form1.
Thank you very much and I hope you can help me.
Walter Roberson
2019 年 6 月 1 日
guidata(hObject, handles);
In form2 you should put in a breakpoint at
handles.form1_h = findobj(groot, 'tag', 'form1');
and step through that, and check whether handles.form1_h is empty . If it is empty, then your form1 GUI is not really named form1 .
Pedro Guevara 2019 年 6 月 2 日
The problem was that the line of code should be called: guidata (hObject, handles); Thank you. Another concern If I want to pass more data to my "form2" GUI how could I get it?

サインイン to comment.



Translated by