Hi,
I have a GUI where I'd like to define different colormaps:
I create a variable name in the GUI:
% --- Executes on selection change in OutputColormap.
function OutputColormap_Callback(hObject, eventdata, handles)% some code
contents = cellstr(get(handles.OutputColormap,'String'));OutputColormap = contents{get(handles.OutputColormap,'Value')};
Then I read it into my script:
cmap1 = eval(OutputColormap);
I know eval seems not to be a good way to do it, but like this it has been the only way so far I've got the colormap matrice the way you would get if you would type this:
cmap1 = hsv;
Then I want to distribute it like this:
% Working code if I do not get the colormap matrice from GUI
n = 1000;cmap = hsv (n);% Code which does not work so far
cmap = cmap1 (n);Error:index exceeds array bounds
I don't know why it does not work as I intend, is it possible that this way (e.g. cmap = hsv (n); ) does only work for the predefined colormap names?
Best Answer