I think this is the line that produces the error:
trainingLabels = [trainingLabels; labels ];
But the problem is with this line:
labels = repmat(trainingSet(digit).Description, numImages, 1);
When you include images that have the description '10', repmat produces a numImages x 2 char array, NOT a numImages x 1 char array. You then vertically concatenate that 2-column array with the trainingLabels array, which only has 1-column, hence the error.
To fix this, you can either convert the labels to strings, if that's appropriate for your application; or you can ensure that the number of columns in labels is always two by beginning single digit labels with a zero.
Hope this helps.