How to apply validation on matlab M-file?

2 次查看(过去 30 天)
I want to put a warning message box at the click of a close button in a matlab figure.
function closed(hObject, eventdata)
close(gcbf);
warndlg('are you sure you want to close','!! Warning !!')
%clear all;
%close;clear
end
however this warning dialog box appears when the window is closed! Where should I put this messagebox exactly!

采纳的回答

Kaustubha Govind
Kaustubha Govind 2011-4-29
Looks like you have your call to warndlg after "close(gcbf)". Try putting it above that.
  1 个评论
Walter Roberson
Walter Roberson 2011-4-29
And use questiondlg() instead of warndlg(), as warndlg() does not give the user any way to chose between closing or not.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by