Matlab: Fixing colormap to specified values when the solutions at a specific value
1 次查看(过去 30 天)
显示 更早的评论
I solved the diffusion equation in 2D geometry with fixed boundary conditions and consumption term. How can add to the colormap a new color specifying a certain level of the chemical concentration within the (x-y) graph ? For example, my colormap goes from dark blue to light blue as the solutions change from 100 at the top to 0 at the bottom, how can I add red color to the colormap showing the locations where the solutions are 20?
0 个评论
回答(1 个)
Image Analyst
2015-2-9
Try something like this:
z=100 * mat2gray(peaks(300)); % Sample data.
imshow(z, []);
% Make colormap.
ramp = linspace(0,1, 100);
blue = ones(1, length(ramp));
colorMap = [ramp; ramp; blue]';
% Make 20'th color red.
colorMap(20,:) = [1,0,0];
colormap(colorMap);
colorbar;
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Red 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!