Hi,
You can get all the Graphics Objects of the preferred type present in MATLAB figure using ‘findall’ function in MATLAB and then delete all the objects using ‘delete’ function in MATLAB.
For instance, try executing this code:
figure;
axis([0 10 0 10]);
rectangle(‘Position’,[1 2 5 6]);
rect = findall(gcf,’Type', 'Rectangle’);
delete(rect);
Refer to this documentation links: