JoshTheEngineer | Explained: Popup Menu GUI [MATLAB] @JoshTheEngineer | Uploaded September 2014 | Updated October 2024, 1 hour ago.
Pop-up menus can be used to make a selection from a list of items. This video shows how to get the user's input from a pop-up menu in a MATLAB GUI.
Tip:
The method described in the video gives you a little bit more information to work with when extracting data from the popup menu, but if you want the most efficient code, you can use the code below.
popVal = get(hObject,'Value');
assignin('base','popVal',popVal);
In this code, you're simply getting the selected value. The first choice is 1, the second choice is 2, and so on. You can then immediately assign this variable back into the base workspace. This code is much simpler, but you also won't have a variable with the strings of all the choices available. In most of my applications, I don't care about the actual strings, just about the value that's selected.
Pop-up menus can be used to make a selection from a list of items. This video shows how to get the user's input from a pop-up menu in a MATLAB GUI.
Tip:
The method described in the video gives you a little bit more information to work with when extracting data from the popup menu, but if you want the most efficient code, you can use the code below.
popVal = get(hObject,'Value');
assignin('base','popVal',popVal);
In this code, you're simply getting the selected value. The first choice is 1, the second choice is 2, and so on. You can then immediately assign this variable back into the base workspace. This code is much simpler, but you also won't have a variable with the strings of all the choices available. In most of my applications, I don't care about the actual strings, just about the value that's selected.