How to resolve empty inputdlg box issue?

조회 수: 6 (최근 30일)
John Doe
John Doe 2020년 7월 12일
댓글: Star Strider 2023년 5월 21일
Hello everyone!
I have a inputdlg box. I want the inputdlg box to cancel the processing if the user pressed OK without giving any input in the inputdlg box. How can I do that?
I know how to cancel the processing if Cancel or the close button is pressed.
Thanks in advance!

채택된 답변

Star Strider
Star Strider 2020년 7월 12일
Try this:
a = inputdlg('Type a number:')
if isempty(a{:})
disp('a is empty') % Information Only To Demonstrate That The Test Works
return
end
fprintf('a = %f\n', str2double(a))
.
  댓글 수: 2
Mpho
Mpho 2023년 5월 21일
Hi, thanks for the helpful answer. Could you please explain what the colon does?
Star Strider
Star Strider 2023년 5월 21일
My pleasure!
The documentation on colon, : can explain it better than I can!

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

추가 답변 (0개)

카테고리

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