I have a 500x500 cell matrix that is updated on every iteration. I'm modelling stochastic processes and new values appear or disappear as a consequence. What i want to do is to give the values -1
and 0
a fixed colorcode (lets say green and blue). All other values (from 1
up to the maximum value found in the matrix) could be anything but the same colors as cells containing -1
or 0
. The colors could be interpolated for all values greater than 0
. I'm aware of the caxis
function but this lets me only exclude the values -1
and 0
or interpolate starting at -1
. Is there any solution to this problem? It needs to be a fast solution as well since the matrix is printed on every iteration...
[solution]
tic
a = randi([-1,10],100,100);
cint = [-1,0,linspace(1,10,10)];
cmap = [0,0,1;0,1,0;autumn(10)];
[~,c] = histc(a,cint);
d = cmap(reshape(c,10000,1),:);
for k=1:3
im(:,:,k) = reshape(d(:,k),100,100);
end
image(im)
toc