nav-left cat-right
cat-right
Matthias Pospiech > Programming > matlab > matlab popupmenu (combobox)

matlab popupmenu (combobox)

The popupmenu of the matlab gui is based on the uicontrol class. Below is a sample code for its usage:
% create text entries in menu
colormapStr{1}= 'blue-red';
colormapStr{2}= 'red-blue';
colormapStr{3}= 'gray';
set(handles.popupmenuColorMap, 'String',colormapStr,'value',1);
 
% get current selection of menu
ColorMapContents = cellstr(get(handles.popupmenuColorMap,'String'));
ColormapSelect = ColorMapContents{get(handles.popupmenuColorMap, 'value')};
 
% select an action
switch ColormapSelect
    case 'blue-red'
        cmap = fliplr(jet(colorDepth));
        colormap(cmap(1:800,:));
    case 'red-blue'
        colormap(jet(colorDepth)); 
    case 'gray'
        colormap(gray(colorDepth)); 
end

Einen Kommentar schreiben

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

*

This blog is kept spam free by WP-SpamFree.