The following Matlab project contains the source code and Matlab examples used for confusion matrix, accuracy, precision, specificity, sensitivity, recall, f score.
function stats = confusionmatStats(group,grouphat)
% group = true class labels
% grouphat = predicted class labels
% OR INPUT
% stats = confusionmatStats(group);
% group = confusion matrix from matlab function (confusionmat)
% stats is a structure array