Hi,
I understand that you are seeking a method to automatically identify the EPSG code from a given projected coordinate system. In MATLAB, this can be achieved using the "wktstring" function, which will output the full CRS in WKT string form, the last ID tag in the WKT string is the 'CoordRefSysCode'.
Below is an example of how to use the function:
wktstring(R.ProjectedCRS,"Format","formatted")
For further details, you might find the following MathWorks documentation helpful:
I hope this helps!