function C = confusionmulti(y1, y2, numclasses)
% returns the confusion matrix for two vectors, assuming
% numclasses binary values in each row
% C is number of classes x number of classes
% e.g. to find confusion matrix for a set of binary targets, compared to some 
% outputs y, on a two-class problem we could use 
% C = confusion(targets, y>=0.5, [1 0]);
% an example where y1 & y2 are equal will lead to a diagonal matrix - no confusion.

for i = 1:numclasses
   for j = 1:numclasses
     C(i,j) = sum(y1(:,i) & y2(:,j));
   end
end