필터 지우기
필터 지우기

Numerical Input in Pop-up box

조회 수: 17 (최근 30일)
Elyse
Elyse 2024년 6월 26일 12:00
댓글: Star Strider 2024년 6월 26일 13:25
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일 12:39
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
Elyse
Elyse 2024년 6월 26일 12:44
This worked, thank you!
Star Strider
Star Strider 2024년 6월 26일 13:25
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by