%Matlab Color mapping
%NOTE: Adjust depth to get more colors
depth=3;
%NOTE: Adjust scale to get larger blocks
scale=2;
x=scale*[0 1 1 0 0];
y=scale*[0 0 1 1 0];
offset=0.1;
figure, hold on
for i=0:depth
   for j=0:depth
      for k=0:depth
         index=i*(depth+1)+j;
         fill(x+index*scale,y+k*scale,[i/depth j/depth k/depth])
         eval(['text(x(1)+(index+offset)*scale,y(1)+(k+offset)*scale,''[' num2str(i/depth) ' ' ...
               num2str(j/depth) ' ' num2str(k/depth) ']'',''FontSize'',7)'])
%         fprintf('Index %d: (%d): %d %d %d\n',index,i*(depth+1)^2+j*(depth+1)+k,i,j,k)
      end
   end
end
axis equal
title('Color Vector Codes for Matlab')
xlabel('NOTE: Zoom in to see all digits of vector')