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!
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!