The issue is that with FINDOBJ, there is no value called 'imrect' in the 'Type' property. To find all the draggable rectangles in the figure, please replace following code in your program:
databox = findobj(gca, 'Type', 'imrect');
with:
databox = findobj(gca, 'Type', 'hggroup', 'Tag', 'imrect');
As you can see, the draggable rectangle is a group object.
Best Answer