# MATLAB: Display data in matrix with two different colour scales, depending on cell value

3d plotscolorcolormapfigureimageMATLABplotplotting

Hi
I have a 20×20 matrix and want to display it as an image. In this image I want to be able to represent two properties of each cell: its value and wether or not this value is above a certain threshold (0.1).
I was thinking about this: to represent cells with a value lower than 0.1 by a green colour. The shade of green must be darker for a lower value and lighter for a higher value (closer to 0.1). If the value is larger than 0.1, it must be represented by a red colour, and its shade must also change from lighter red to darker red (lower => higher).
Is there any way to do this in matlab?
Best regards

``N = 100;g = [zeros(N,1), linspace(100, 255, N)', zeros(N,1)] ./ 255;r = [linspace(255, 100, N)', zeros(N,1), zeros(N,1)] ./ 255;c = colormap([g; r]);``
``A0 = rand(20,20);cutoff = 0.1;A = A0;Alow = A(A0<cutoff);Ahigh = A(A0>cutoff);biggerRange = max([range(Alow) range(Ahigh)]);A(A0<cutoff) = N - round(N * (Alow - min(Alow)) / biggerRange);A(A0>cutoff) = N + round(N * (Ahigh - min(Ahigh)) / biggerRange);image(A)``
``A0 = rand(20,20);cutoff = 0.1;A = A0;Alow = A(A0<cutoff);Ahigh = A(A0>cutoff);A(A0<cutoff) = round(N * (Alow - min(Alow)) / (max(Alow) - min(Alow)));A(A0>cutoff) = N + round(N * (Ahigh - min(Ahigh)) / (max(Ahigh) - min(Ahigh)));image(A)``