MATLAB: Is there a better way to do the following undocumented thing

findclassfindpackageundocumented

I have a piece of 3rd party code with the following lines, which worked as needed in R2013b,
hgp = findpackage('hg');
axesC = findclass(hgp,'axes');
LimListener = handle.listener(imAxes,...
[axesC.findprop('XLim') axesC.findprop('YLim')],...
'PropertyPostSet',@localLimitListener);
This code uses undocumented functions findpackage and findclass . Now that I've upgraded to R2014b, their behavior has changed and the code no longer works properly. In particular, findpackage('hg') now just returns empty, [] .
Was there a better way to have implemented this in R2013b, one which avoids undocumented MATLAB and which will continue to work in R2014b?

Best Answer

I think I figured it out. It can all be condensed to
LimListener = addlistener(imAxes,{'XLim','YLim'},'PostSet',@localLimitListener);