function M = cls_ConfusionMatrix(GT, T)%calculate the classes (unique elements in the GT array)C = unique(GT);nc = length(C); %calculate the number of classesM = zeros(nc); %allocate space for the confusion matrix%for each classfor ci = 1:nc for cj = 1:nc M(ci, cj) = nnz((GT == C(ci)) .* (T == C(cj))); endend