필터 지우기
필터 지우기

use a custom made gui in another .m file

조회 수: 6 (최근 30일)
Joseph Catanese
Joseph Catanese 2021년 5월 28일
편집: Joseph Catanese 2021년 6월 1일
i created a gui file and i want to run it in another m file such that if questdlg is one of the 3 like blue it will run the gui and save the answers from the gui into the m file to be further evaluated.
the help would be greatly apreciated
for instance
.m script that calls the gui
cars=0;red=0;
cars=questdlg('color of car','Select','Red','blue','c');
switch cars
case 'Red'||'Blue'
cargui
end
disp(carguiredqt)
disp(carguiblueqt)
cartot=carguiredqt+carguiblueqt
within the gui are checkboxes that ask for the colors when clicked a edit box becomes visible asking for the quantity of that color. this is the value i want to use in the other script.
ive got all the values i want returned in a push button callback so when the button is pushed it gets the values entered i just dont know how to get them out of the button press to the other script to use
then if it is red or blue it will call the gui i tried using call and run. and i want to take whatever values entered in the gui and continue runing them in the m file.
  댓글 수: 2
Walter Roberson
Walter Roberson 2021년 5월 28일
Was the GUI created with GUIDe or with App Designer?
Joseph Catanese
Joseph Catanese 2021년 5월 28일

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

답변 (2개)

Walter Roberson
Walter Roberson 2021년 5월 28일
In GUIDE, you will need to go into cargui.m and uncomment the uiwait() or waitfor() in the Open Function Callback, and you will need to make sure that whatever value you want to have returned is selected in the Output Function Callback.
Then in your other gui, you will need to assign the output of cargui to a variable.
Normally when you call a GUIDE GUI, the output is the figure number, and the GUI does not wait, but there is commented code in the Open Function Callback to make it wait, and in that case what gets returned is controlled by the Output Function Callback.
  댓글 수: 12
Joseph Catanese
Joseph Catanese 2021년 5월 29일
i cant get the variables to get pulled to the script but i can get the fig to work
Joseph Catanese
Joseph Catanese 2021년 6월 1일
편집: Joseph Catanese 2021년 6월 1일
cars = questdlg('color of car','Select','Red','blue','c');
switch cars
case {'Red', 'Blue'}
result = cargui;%-------This
otherwise
result = struct('redqt', nan, 'blueqt', nan, 'greenqt', nan);
end
carguiredqt = result.redqt;
carguiblueqt = result.blueqt;
carguigreenqt = result.greenqt;
disp(carguiredqt)
disp(carguiblueqt)
cartot = sum([carguiredqt,carguiblueqt,carguigreenqt], 'omitnan');
@Walter Roberson on this i set it up like this but when it runs it it shows the answer for carguiredqt before it allows me to enter a number in the figure.

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


Image Analyst
Image Analyst 2021년 5월 29일
You need to call guidata() at the end of the function, not the beginning. guidata() is needed anytime you change a field of handles that is not connected to a specific control on the form, like handles.output -- it's just a field, not a widget on the GUI so you need guidata() after you make a change to handles.output.

카테고리

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

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by