I have a matlab gui that shall contain 4 plots. The first plot shall be updated if a different file is selected in a list. the other 3 shall only be visible (and be calculat
I now solved it with
function z_removePlots(handles)
if (isfield(handles,'image') && isfield(handles.image,'hplot'))
if ishandle(handles.image.hplot)
delete(handles.image.hplot);
delete(findall(gcf,'tag','Colorbar'));
handles.image.hplot = 0;
set(handles.axesImage, 'Visible', 'off');
end
end
if (isfield(handles,'contour') && isfield(handles.contour,'hplot'))
if ishandle(handles.contour.hplot)
delete(handles.contour.hplot);
handles.contour.hplot = 0;
ClearLinesFromAxes(handles.axesContour)
set(handles.axesContour, 'Visible', 'off');
end
end
guidata(handles.output,handles);
with
function ClearLinesFromAxes(axisObj)
if ishandle(axisObj)
handles2delete = get(axisObj,'Children');
delete(handles2delete);
end