フィルターのクリア

GUI with 3 Popup menus, Nested Ifs, and 1 condition push button

1 回表示 (過去 30 日間)
Gbola
Gbola 2022 年 11 月 20 日
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 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品


リリース

R2012b

Community Treasure Hunt

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

Start Hunting!

Translated by