Clean up Colortable in a MATLAB EPS file.
EPSCLEANCOLORDICT(EPSFILE) scans the MATLAB-generated EPS file specified by the string EPSFILE and cleans up Colortable dictionary key-value pairs.
The MATLAB-generated EPS files defines a subdictionary inside of main section (which is not the most elegant solution but works). New color key-value pairs are inserted to the dictionary as the figure is drawn. This function scans the EPS file, picks up all the color keys, remove unused colors, and gather all color definitions at the top.
EPSCLEANCOLORDICT(EPSFILE,OUTFILE) saves the modified EPS data to a file specified by the string OUTFILE.