フィルターのクリア

What is wrong with my exit button?

1 回表示 (過去 30 日間)
sadel
sadel 2011 年 6 月 8 日
I have this code on an exit button and when I hit the button and select 'yes' to save the data I receive the figure again. Why? What am i doing wrong? And why when I select 'no', I receive the questiondlg again?
answer=questdlg('Save changes to the model?',...
'Exit ADADCS Confirm','Yes','No','Cancel','Cancel');
switch answer
case 'Yes'
[filename,pathname] = uiputfile('default','Save your GUI settings');
if pathname == 0 %if the user pressed cancelled, then we exit this callback
return
end
%construct the path name of the save location
saveDataName = fullfile(pathname,filename);
%saves the gui data
hgsave(saveDataName);
delete(hObject);% Hint: delete(hObject) closes the figure
close all;
case 'No'
delete(hObject);% Hint: delete(hObject) closes the figure
close all;
end

採用された回答

Paulo Silva
Paulo Silva 2011 年 6 月 8 日
I tried your code and it works without any of the problems you describe, they might be caused by other code.
Just two small suggestions, the close all doesn't need the ; at the end, it's common to both Yes and No responses (also the cancel got the return line), you can remove those two "close all" lines put it after the end of that code.
  6 件のコメント
Paulo Silva
Paulo Silva 2011 年 6 月 8 日
Unless you are trying to close several figures you don't need the close all, just use the delete(... to delete the figure after that code.
sadel
sadel 2011 年 6 月 8 日
This is the answer: delete(gcf). thank you!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by