problems using my custom color map
5 次查看(过去 30 天)
显示 更早的评论
Hi, I made a custom colormap (size = 15 x 3) and now I am trying to use it but it is not working. Here is the code:
...plotting code
set(gcf,'Colormap',mycmap)
And then I get this error:
Undefined function or variable 'mycmap'.
The mycmap variable is loaded into my workspace. Any help is appreciated.
Thanks, Dan.
0 个评论
采纳的回答
per isakson
2013-4-20
Is
set(gcf,'Colormap',mycmap)
executed in the base workspace?
5 个评论
Walter Roberson
2013-4-22
set(gcf, 'Colormap', evalin('base', 'mycmap'))
Are you familiar with the concept of MATLAB "workspaces" ?
更多回答(1 个)
Image Analyst
2013-4-20
You can try using the colormap() function instead. Does this work for you?
grayImage = imread('cameraman.tif');
image(grayImage);
mycmap = jet(15);
% set(gcf,'Colormap',mycmap)
colormap(mycmap);
colorbar
Apparently you did not specify mycmap like you thought. Put this line right before your call to set():
whos mycmap
If it says it's undefined, then it is undefined, not 15 by 3 like you thought.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!