MATLAB: Initialize contents of popupmenu in GUIDE

guidepopupmenustring property

I am writing a GUI in GUIDE which contains a popup menu. In the Property Inspector the String property is empty. The contents of the menu must be filled during execution and are assigned values from a structure as such:
a = {AlertFD.name};
set(handles.popupmenu1, 'String', a);
and the user input is assigned to b:
b = get(handles.popupmenu1, 'Value');
The problem occurs when I run the GUI: when I first click on the menu, I see an empty cell. I click on the empty cell and then the first element of cell a is shown and automatically passed as user input to b , even though I do not wish to select it.
Any solutions? Thanks, George

Best Answer

You need to set both the string and the value in the OpeningFcn function (if that doesn't work, then put it in the OoutputFcn function). Since you did not set the value (you only retrieved it) no item will be selected/shown when your GUI starts up.