Borrar filtros
Borrar filtros

Colour data from a vlaue

1 visualización (últimos 30 días)
toby peterken
toby peterken el 7 de Jul. de 2015
Respondida: Titus Edelhofer el 7 de Jul. de 2015
I have a value that ranges from roughly -5 to 10. From this I would like it so that when the value is high it returns red (or white) and for low blue/black with other colours in the middle.
However, all the colormap tutorials/references I have seen are for plotting graphs. I need hexadecimal values of the RGB so that I can write a KML file with them
Any help would be appreciated.

Respuestas (1)

Titus Edelhofer
Titus Edelhofer el 7 de Jul. de 2015
Hi Toby,
yes, colormap is usually used in connection with graphics. But there is nothing wrong in using the values for your purpose:
% get the values of a colormap, e.g. jet
f = figure('visible', 'off');
cm = colormap('jet');
close(f);
% limits
cmin = -5;
cmax = 10;
% now interpolate e.g. at 7
val = 7;
if val<=cmin
index = 1;
elseif val>=cmax;
index = size(cm,1);
else
index = round(1 + (val-cmin) * (size(cm,1)-2)/(cmax-cmin));
end
% grab corresponding row:
rgb = cm(index,:);
Titus

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by