MATLAB: Print specific figure in GUI

guiprint

Welcome All
I hope to be alright 🙂
I make GUI in matlab , it's contain print button because i want to print specific figure in my GUI
I try that :
function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved – to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
% Callback function run when the Print menu item is selected
h = handles.axes2;
print(h)
but, an Error was Appear !!
Plz help me 🙁

Best Answer

Hi,
the error message tells you the problem: you can only print figures, not axes. I assume though, that handles.axes2 is an axes handle, not the figure handle. You probably need to have
h = handles.figure1;
instead.
Titus