Radio button to ON-OFF figure visibility

조회 수: 2 (최근 30일)
adi kul
adi kul 2016년 7월 18일
답변: adi kul 2016년 7월 20일
Hello All, I have been working on GUI. Now I am stuck with one requirement, which is to have a radio button to ON-OFF the image visibility. I have the "Calculate" push button which will calculate in user defined loops where I have 3 images per loop. Every time the script runs the image pops up. If the loops are huge in number the calculation process takes more time. So I want to have a radio button so that when selected the images will popup meaning visibility will be ON while unselected, the figures will not pop up so the user can minimize the GUI and work on something else till a message pops up as calculation is completed. I take user defined location to save the images so user will get to the images whenever he wants.
I tried with figure('Visible','off') and it worked well so I just want to add it with a radio button to give user the choice to ON-OFF images.
  댓글 수: 10
Adam
Adam 2016년 7월 20일
Are you using a radio button or a checkbox? Your question talks about a radiobutton, but your code since then suggests you are using a checkbox.
adi kul
adi kul 2016년 7월 20일
I previously tried with checkbox, but could not make it work so someone suggested to make it radio button hence name is still checkbox but the button is radiobutton.

댓글을 달려면 로그인하십시오.

채택된 답변

adi kul
adi kul 2016년 7월 20일
Thank you all for your help. I managed to Solve it using
if get(handles.checkbox2, 'Value')
Visibility = 'on';
else
Visibility = 'off';
end
figure('Visible', Visibility)

추가 답변 (1개)

Adam
Adam 2016년 7월 19일
편집: Adam 2016년 7월 19일
Right click on your radio button group panel (you should put radio buttons in a button panel if they aren't already) and select the SelectionChangedCallback if you are in GUIDE. This will create the function for you then you simply code it as e.g.
set( myFig, 'Visible', hObject.String )
for some figure if you name the options on the radio buttons as 'On' and 'Off'

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by