Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Help and Support on Guide - Popup menus, condition Pushbutton and block ifs (nested ifs)

조회 수: 1 (최근 30일)
Gbola
Gbola 2022년 10월 22일
마감: Rik 2022년 10월 22일
Dear All,
I am creating a GUI with GUIDE to display the result (output) of combining three strings, each string from the 3 popup menus namely ‘A’, ‘B’ and ‘C’.
The popup menu ‘A’ contains four strings: 0.0 to 0.25, 0.25 to 0.5, 0.5 to 0.75 and 0.75 to 1.0; popup menu ‘B’ contains the following 4 strings: K1, K2, K3 and K4 while popup menu ‘C’ contains the following 4 strings: L1, L2, L3 and L4.
I also have one static text ‘Display’ for displaying the output (result) of the combination of the 3 strings, selecting one string each, from the 3 popup menus.
Lastly, I have one condition pushbutton ‘Combine’ which function is to send the result of combining a set of 3 strings to the static text ‘Display’, after pressing the condition pushbutton which will use a series of nested If-elseif-else-end statements to test each of the conditions in order to determine and display an appropriate output (result) for each combination of the three strings.
For instance, if string 0.0 to 0.25 was selected from popup menu ‘A’, string K1 from popup menu ‘B’ and string L1 from popup menu ‘C’, the popup menu could send a word, e. g. Lion or any other word as a result (output) to the static text ‘Display’.
Also, if string 0.25 to 0.5 was selected from popup menu ‘A’, string K2 from popup menu ‘B’ and string L2 from popup menu ‘C’, the popup menu could send a word, e. g. Elephant or any other word as a result (output) to the static text ‘Display’.
Also, if string 0.5 to 0.75 was selected from popup menu ‘A’, string K3 from popup menu ‘B’ and string L3 from popup menu ‘C’, the popup menu could send a word, e. g. Tiger or any other word as a result (output) to the static text ‘Display’.
Also, if string 0.75 to 1.0 was selected from popup menu ‘A’, string K4 from popup menu ‘B’ and string L4 from popup menu ‘C’, the popup menu could send a word, e. g. Leopard or any other word as a result (output) to the static text ‘Display’.
Summarily, I have 3 popup menus ‘A’, ‘B’ and ‘C’, 1 static text ‘Display’ and 1 condition pushbutton ‘Combine’ on a figure (figure1).
Kindly do the needful.
Cheers.
2 Comments
Image Analyst on 11 Oct 2022 at 12:58
Can you attach the .fig file and the .m file so we can try it?
Gbola on 16 Oct 2022 at 0:20
Dear All,
Kindly find the attached .fig and the .m file as requested.
>> animals
Error messages displayed on running the code:
Undefined function or variable 'popupValue1'.
Error in animals>pushbutton1_Callback (line 232)
if popupValue1=='0.0-0.25' && popupValue2==K1 && popupValue3==L1
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in animals (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)animals('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Kind regards,
Gbola.
  댓글 수: 1
Rik
Rik 2022년 10월 22일
You should not use == to compare two char vectors. That is probably what is going wrong here.
What you also might want to reconsider is your use of GUIDE. Fully building your GUI from code makes you have much more control and flexibility.

답변 (0개)

제품


릴리스

R2012b

Community Treasure Hunt

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

Start Hunting!

Translated by