Numerical Input in Pop-up box

4 次查看(过去 30 天)
Hi, I have a code that asks for inputs of numbers from the user. Currently it asks for inputs in the command window, but I would like it to ask in a pop-up box. When I use the inputdlg command it won't accept the values as numbers for later use, so I was wondering if there is a different way to ask the user for numbers in a menu so that it will know they are numbers.
This is the code that currently works for the command window:
askstartinch="What inch did you start from?\n";
start_inch=input(askstartinch);
askendinch="What inch did you end at?\n";
end_inch=input(askendinch);
asktrial="What trial number is this?\n";
trial=input(asktrial);
This is the code that I tried with the popup boxes, but it won't accept the values as numbers for later use in the code:
start_inch=inputdlg("What inch did you start from?");
end_inch=inputdlg("What inch did you end at?");
trial=inputdlg("What trial number is this?");
I would perfer the menu to have all 3 questions in popup box, but either way works I just can't seem to get it work. Thanks!

采纳的回答

Star Strider
Star Strider 2024-6-26
Try something like this —
trial_info = inputdlg(["What inch did you start from?","What inch did you end at?","What trial number is this?"], "Trial Info:", [1 50]);
start = str2double(trial_info{1})
finish = str2double(trial_info{2})
trial_nr = str2double(trial_info{3})
Make appropriate changes to get the result you want.
.
  2 个评论
Star Strider
Star Strider 2024-6-26
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by