フィルターのクリア

Matlab: Fixing colormap to specified values when the solutions at a specific value

1 回表示 (過去 30 日間)
Fehaid Alshammari
Fehaid Alshammari 2015 年 2 月 9 日
回答済み: Image Analyst 2015 年 2 月 9 日
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 Center および File ExchangeColormaps についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by