To standardized my figure export process I use a custom defined printfigs.m call at the end of each script. One of the key things it does is timestamp and add a path to each figure at the top so that I can have a record of which script generated which figure.
To prevent this from overlapping any title's, annotations, or other parts of the figure, I want to resize the figure by adding a margin to the top that I can then use to place my annotation without potentially obstructing anything in the figure. I want a code that can take any figure and stretch the margins without disturbing it's contents.
To accomplish this, I've written this little code which I've been using for the bast two years on 2016b with little issue, but now it fails in 2018b quite frequently.
function  = resizeFig(t, l, b, r)
fh = gcf();
objs = findobj(fh,'-property','position');
oPos = get(objs,'position');
ind = cellfun(@(C) size(C,2)==4,oPos);
objs = objs(ind);
oPos = oPos(ind);
nPos = cellfun(@(C) C+[l,b,0,0],oPos,'uniformoutput',false);
for i = 1:length(objs)
Now I do hope there is a smarter way to do this to improve performance, but more importantly the line:
oPos = get(obs,'position');
tends to fail with this error:
Error using matlab.graphics.Graphics/get
No public property 'Position' for class
this surprises me since the previous line is purposefully chosen to define objs as only those with the position property, though it now complains that it doesn't have that property. The same occurs if I use findall instead of findobj.
What has changed since 2016b and 2018b to cause this to fail?