MATLAB: How to create two push buttons to change the visibility of an image

imagesmatlab guipush button

I want to create a push button to make an image (jpg) visible, and another to make that same image disappear.

Best Answer

Did you display your image already anywhere? Did you store its handle?
function displayImage_Callback(hObject, EventData, handles)
handles.image = image(rand(100, 100, 3));
guidata(hObject, handles);
end
function hideImage_Callback(hObject, EventData, handles)
set(handle.image, 'Visible', 'off');
end
function showImage_Callback(hObject, EventData, handles)
set(handle.image, 'Visible', 'on');
end
Now create the two buttons and attach the callbacks.