How to resolve empty inputdlg box issue?

4 次查看(过去 30 天)
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 中查找有关 Image Processing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by