How to resolve empty inputdlg box issue?

4 views (last 30 days)
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!

Accepted Answer

Star Strider
Star Strider on 12 Jul 2020
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 Comments
Mpho
Mpho on 21 May 2023
Hi, thanks for the helpful answer. Could you please explain what the colon does?
Star Strider
Star Strider on 21 May 2023
My pleasure!
The documentation on colon, : can explain it better than I can!

Sign in to comment.

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!