How to apply validation on matlab M-file?

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일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by