Within a single popup dialog box, how to request multiple user inputs to define variables?

조회 수: 30 (최근 30일)
I have four separate boxes popup for a user to define variables r, s, n, and d:
r = str2double (inputdlg ('Input row number.')); % Row number.
s = str2double (inputdlg ('Input section number.')); % Section number.
n = str2double (inputdlg ('Input quantity of images.')); % Quantity of images.
d = str2double (inputdlg ('Input distance from vine [ft].')); % Camera distance from vine [ft].
Is there a way for the user to define these variables using one popup box? Thank you!

채택된 답변

Mischa Kim
Mischa Kim 2014년 1월 31일
Try
prompt = {'Input dialog'};
name = 'Input dialog';
numlines = 2;
dlg_ans = inputdlg(prompt, name, numlines);
then use
dlg_ans{1}(1,:)
dlg_ans{1}(2,:)
  댓글 수: 1
Mark
Mark 2014년 1월 31일
Thanks for the step in the right direction! I now have:
prompt = {'Input: row #, section #, image quantity, vine distance'};
name = 'Input';
numlines = 4;
dlg_ans = inputdlg(prompt, name, numlines);
dlg_ans{1}(1,:)
dlg_ans{1}(2,:)
dlg_ans{1}(3,:)
dlg_ans{1}(4,:)
Are you aware of any method for making this single dialog box contain four line-specific prompts (rather than the single "prompt" heading)?

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2014년 1월 31일
Yes, inputdlg() accepts a cell array of strings for the several prompts.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by