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?

回答(1 个)

Image Analyst
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;

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by