MATLAB: Save specific portion of GUI screen

guisavestatic text

Hi All,
I have a GUI screen that I created with GUIDE. It has two axes plots, some static text fields, buttons and check boxes. I want to save a specific portion of the screen when I hit the save button without printing the buttons or check boxes. I tried:
print(gcf,'-noui','-djpeg',fileName);
but this leaves out the static text fields on the save/print. I was wondering if anyone had any solutions to this. I'd be open to trying anything.

Best Answer

ctl = findall(gcf, 'type', 'uicontrol', '-regexp', 'Style', 'checkbox|pushbutton');
ctl_state = get(ctl, 'Visible');
set(ctl, 'Visible', 'off');
print(gcf, '-djpeg', fileName);
set(ctl, 'Visible', ctl_state);