function [cmap]=colourgend(IDX)
%Generates a green-to-red matrix based on the cluster index from a
%kmeans clustering, for the later colouring of individual data points on a
%scores plot. Although they have to be generated differently, this mapping 
%is matched precisely by the colourmap generated in-situ for the scores
%cluster maps, so that clusters can be visualised and matched
%appropriately on a broad scale.
%
%OUTPUTS: colourmap matrix
idxrows=size(IDX,1);
k=max(IDX);
cmap=zeros(idxrows,3);
cmap(:,1)=rangescale(IDX);
cmap(:,1)=cmap(:,1)+(1/(k+1));
cmap(:,1)=cmap(:,1)/max(cmap(:,1));
cmap(:,2)=1-cmap(:,1);
end