# MATLAB: Facing error in combining two m-files

digital image processinghand detectionskin detection

I have two codes having names skin_detection5.m and hand_detection4.m
I am trying to combine these two m-files but getting error.
combination.m is a file in which I tried to combine above mentioned m-file.
Input Image for skin_detection5.m
Input Image for hand detection
Both skin_detection5.m and hand_detection4.m are working fine for given input images. But I am trying to make a one m-file so that I do can both things i.e. skin detection and hand detection by running one m-file. But getting error mentioned below:
Attempted to access sortingIndexes(2); index out of bounds becausenumel(sortingIndexes)=1.Error in combination (line 129)handIndex = sortingIndexes(2); % The hand is the second biggest, face is biggest.

binaryImage = grayImage < 128;
binaryImage = ~grayImage;
grayImage = bin;