I'm trying to generate a colormap in MATLAB given three colors, a high extreme, zero, and low extreme. My thought process has been to loop from the high extreme to the middle and store each step to a a 3xN (first column is R, second is G, and third is B)matrix. So I'm using:
%fade from high to zero
oldRed=high(1);
oldGreen=high(2);
oldBlue=high(3);
newRed=mid(1);
newGreen=mid(2);
newBlue=mid(3);
currentRed=oldRed; currentGreen=oldGreen; currentBlue=oldBlue;
for x=1:steps
currentRed=oldRed+((x*(newRed-oldRed))/(steps-1));
currentGreen=oldGreen+((x*(newRed-oldRed))/(steps-1));
currentBlue=oldBlue+((x*(newRed-oldRed))/(steps-1));
cmap=[cmap;[currentRed currentGreen currentBlue]];
end
Then I would do the same thing going from the zero value to the low extreme. However my code is not giving me any kind of useful matrix. Would someone be able to help me with how I should approach this?