Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

popup menu string in matlab gui?

421 views
Skip to first unread message

Martin Tegg

unread,
Jun 18, 2007, 9:10:47 PM6/18/07
to
I am having trouble creating a Matlab Gui. I have created the gui
using GUIDE, and now I would like to populate a pop-up menu with an
array (A list of dates) from a seperate m-file. Using GUIDE, I have
created the pop-up menu, and have edited the string so that it is
blank. However, I am confused as to how to write the m-file code so
that the pop-up menu is populated with the dates. Can anyone help?

Madincea Vasile

unread,
Jun 18, 2007, 10:42:46 PM6/18/07
to
To select an item from the popup menu use:

val = get(handlePOPUPMENU,'Value');
string_list = get(Scenario_Lister,'String');
selected_string = string_list{val};

SelectedItem = val;

To populate the popup menu use:

string_list{1} = date1;
string_list{2} = date2;
...etc...
set(handlePOPUPMENU,'String',string_list);

Hope it helps...

Vasi

Martin Tegg

unread,
Jun 18, 2007, 10:57:20 PM6/18/07
to
Thanks for this. Can you tell me where to put the code? GUIDE has
automatically created two functions in the m-file. The first is
function POPUPMENU_Callback(hObject, eventdata, handles)

The second is:
function POPUPMENU_CreateFcn(hObject, eventdata, handles)

Do I put the populating code under the first one or the second one,
or somewhere else entirely?

Madincea Vasile

unread,
Jun 18, 2007, 11:16:19 PM6/18/07
to
normally, as long as you have the handle, you can do this anywhere,
but it is better to put it in the createFcn.
Good luck !!!

Martin Tegg

unread,
Jun 25, 2007, 8:27:16 PM6/25/07
to
Thanks its working now. The trick was to get the string as a cell
array, not a double matrix
0 new messages