function cmatrix=cmatrixcalc(Ypred, Ytrue, nc)
    ncts=max(Ytrue);
    
    if ncts>nc
        cmatrix=zeros(ncts,nc);
    else
        cmatrix=zeros(nc,nc);
    end
    
    for i=1:length(Ytrue)
        cmatrix(Ytrue(i), Ypred(i))=cmatrix(Ytrue(i), Ypred(i))+1;
    end
end