"Greg " <firstname.lastname@example.org> wrote in message <email@example.com>... > In my GUI axes (axes1) I initialize my GUI with a logo thusly: > > function axes1_CreateFcn(hObject, eventdata, handles) > % hObject handle to axes1 (see GCBO) > % eventdata reserved - to be defined in a future version of MATLAB > % handles empty - handles not created until after all CreateFcns called > > logo = imread('ARA_Logo.jpg'); > imshow(logo) > > % Hint: place code in OpeningFcn to populate axes1 > > In a later button press I want to clear the logo and then replace it. I first clear the logo like this: > arrayfun(@cla,findall(0,'type','axes')); > > I plot some data to another axes like this (which works fine): > axes(handles.axes2); > imshow(images.img1) > > I then switch back to axes one and try to plot like this: > axes(handles.axes1) > imshow(compimage) > > I get the following error: > Reference to non-existent field 'axes1'. > > The only difference between the successful plot in axes2, and the failure in axes1, is I initialize a figure in the create function of axes1.
I don't see how you can "switch back to axes one" once you delete it with the cla command. (That's what the error message is telling you.)
Perhaps you can simply hide the axes one stuff (i.e., set its Visible property to off). Then after you replace it, reset the axes one Visible property back to on (unhide it).