Hide image in GUI using visible on/off

I am trying to change the visibility of an image through the following commands:
set(handles.axes1,'visible','off') %hide the current axes
set(get(handles.axes1,'children'),'visible','off') %hide the current axes contents
However, an error is generated since it does not recognize the axes:
Reference to non-existent field 'axes1'.
Error in VibrationModel>MechSeal_Callback (line 82)
set(handles.axes1,'visible','off') %hide the current axes
The create function for the image is given by:
% --- Executes during object creation, after setting all properties.
function axes1_CreateFcn(hObject, eventdata, handles)
LipSeal=imread('Lip-Seal.jpg');
imagesc(LipSeal);
axis off; %remove axis from image

 採用された回答

Image Analyst
Image Analyst 2014 年 12 月 9 日

0 投票

I never put anything in the create function.
In your MechSeal_Callback function put this line:
handles
Tell us what it spits out to the command window. Paste it back here.

1 件のコメント

Maarten
Maarten 2014 年 12 月 9 日
I already found the problem. I defined the image in the create function of the axis, but I have to define it in the function for the push button, which should turn the image visibility off.
It works with this code now:
MechSeal=imread('Mechanical Seal.jpg');
handles.axes1=imagesc(MechSeal);
set(handles.axes1,'visible','off') %hide the current axes
set(get(handles.axes1,'children'),'visible','off') %hide the current axes contents
axis off;

サインインしてコメントする。

その他の回答 (1 件)

Orion
Orion 2014 年 12 月 9 日

1 投票

Obviously, axes1 is not a field of your structure of handles.
put a breakpoint a the line set(handles.axes1,'visible','off') and check the data handles.
If axes1 is not a field of it, then there is something wrong with your gui, check the tag of your axes objects in guide (maybe you changed it?), and try to regenerate the code, see if axes1 is still not part of handles.

4 件のコメント

Maarten
Maarten 2014 年 12 月 9 日
編集済み: Maarten 2014 年 12 月 9 日
I checked the tag of the axes and I did not change it.
I keep having those difficulties with tags, I guess..
matt dash
matt dash 2014 年 12 月 9 日
Then likely somewhere in your code you are doing something to clear handles.axes1. Try putting breakpoints in various places in your code and check to make sure handles.axes1 exists at each point, e.g. at the beginning and end of your opening_fcn, and at the beginning of MechSeal_Callback.
Orion
Orion 2014 年 12 月 9 日
Also, regarding to your previous question, are you using the right structure of handles (MainGui vs SubGui) ?
Maarten
Maarten 2014 年 12 月 9 日
No Orion, cause this was about the main GUI only. Thanks for the help though. Found the problem, see above.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeImages についてさらに検索

製品

質問済み:

2014 年 12 月 9 日

コメント済み:

2014 年 12 月 9 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by