Matlab: Fixing colormap to specified values when the solutions at a specific value
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 9 Feb 2015
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 Comments
See Also
Categories
Find more on Red in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!