GUI with 3 Popup menus, Nested Ifs, and 1 condition push button
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear All,
I am creating a GUI to display the result (output) of combination of 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 (numeric values); popup menu ‘B’ contains the following 4 strings: K1, K2, K3 and K4 (non-numeric values) while popup menu ‘C’ contains the following 4 strings: L1, L2, L3 and L4 (non-numeric values).
The 3 strings are to be combined to determine an animal’s name by selecting a string from each of the 3 popup menus to form the name of that animal and thereby assign an animal's name (as stated in the nested if statements) and thereafter display the appropriate name of the animal in the control named edit1. 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 pushbutton1 should assign the word “Lion” as a result (output) and send same to the control named edit1.
Also, if string 0.0 to 0.25 was selected from popup menu ‘A’, string K1 from popup menu ‘B’ and string L2 from popup menu ‘C’, the pushbutton1 should assign the word “Parrot” as a result (output) and send same to the control named edit1.
Also, if string 0.0 to 0.25 was selected from popup menu ‘A’, string K2 from popup menu ‘B’ and string L1 from popup menu ‘C’, the pushbutton1 should assign the word “Goat” as a result (output) and send same to the control named edit1.
Also, if string 0.0 to 0.25 was selected from popup menu ‘A’, string K2 from popup menu ‘B’ and string L2 from popup menu ‘C’, the pushbutton1 should assign the word “Antelope” as a result (output) and send same to the control named edit1. etc.
On running the code, The GUIDE window appeared but on selecting a set of three strings (one from each popup menu) and pressing the control named "Combine" (a pushbutton) on the figure named fig1.
The below error messages were displayed in the command window:
>> animals3
Attempt to reference field of non-structure array.
Error in animals3>pushbutton1_Callback (line 173)
popupValue1 = handles.popupmenu1.Value; % Get index of selected item. 1, 2, 3, etc.
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in animals3 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)animals3('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I have attached the .fig and the .m files for confirmation and testing purposes.
Kindly do the needful.
Cheers.
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!