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 |
% 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
Ähnliche Beiträge