does anyone knows about to clear the figure window??

조회 수: 2 (최근 30일)
ARYA NAYAK
ARYA NAYAK 2016년 12월 24일
댓글: Image Analyst 2017년 2월 4일
i used clf function to clear the figure. it will clears all the option in the figure. i need menu options. clf functions clears menu options too.
what to do now??? help me please.....

채택된 답변

Walter Roberson
Walter Roberson 2016년 12월 24일
delete(findobj('Type', 'axes'))
  댓글 수: 6
ARYA NAYAK
ARYA NAYAK 2016년 12월 25일
delete figure deletes all the items. it will delete menu items too.
i already did coding for menus.
deleting and recreating of menus does creation of menus itself not previously coded programs. it won't works when deleting figure and creating one more time.
Image Analyst
Image Analyst 2016년 12월 25일
You already have lines of code to create menus, so what's the problem in using it again?
I don't know what you mean by previously coded programs. If you have a GUI made with GUIDE you wouldn't want to do that, but if you built all your controls manually with uicontrol, uimenu, uitable, etc. then it's easy to just blow away the figure, recreate it, and add the menu again. I don't know why you say it won't work. See my other answer with the demo.

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

추가 답변 (2개)

Image Analyst
Image Analyst 2016년 12월 25일
What if you just delete it and recreate it:
hFig = figure();
% Now put stuff on it with uicontrol()
% Your code goes here.....
% Now clear them away by deleting and recreating a blank figure.
delete(hFig);
hFig = figure();

Image Analyst
Image Analyst 2016년 12월 25일
Try this demo:
% Create a new figure.
hFig = figure('MenuBar','None');
% Create menu
mh = uimenu(hFig,'Label','Find');
frh = uimenu(mh,'Label','Find and Replace ...',...
'Callback','disp(''goto'')');
frh = uimenu(mh,'Label','Variable');
uimenu(frh,'Label','Name...', ...
'Callback','disp(''variable'')');
uimenu(frh,'Label','Value...', ...
'Callback','disp(''value'')');
% Now put other stuff on it with uicontrol()
% Your code goes here.....
plot(1:10);
uiwait(msgbox('Click OK to clear figure'));
% Now clear them away by deleting and recreating a blank figure.
delete(hFig);
hFig = figure();
% Create menu
mh = uimenu(hFig,'Label','Find');
frh = uimenu(mh,'Label','Find and Replace ...',...
'Callback','disp(''goto'')');
frh = uimenu(mh,'Label','Variable');
uimenu(frh,'Label','Name...', ...
'Callback','disp(''variable'')');
uimenu(frh,'Label','Value...', ...
'Callback','disp(''value'')');
  댓글 수: 3
Walter Roberson
Walter Roberson 2017년 2월 4일
Remove the "Function menu_callback" line that you have. Replace it with
function MENU
now you can call it as
MENU
Image Analyst
Image Analyst 2017년 2월 4일
ARYA, it looks like you're using GUIDE, so why don't you just use the menu editor icon in GUIDE to create a menu and put code into its callback?

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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by