How to have a user input prompt more user inputs?

I am writing a script that asks the user to input the number of layers in a composite. If the user inputs "n" layers, I then need "n" number of input dialog boxes to appear and prompt the user to enter information about each layer. Can someone please help???
Thank you.

댓글 수: 1

dpb
dpb 2014년 3월 19일
Read the returned input, check for validity/sanity, then begin a for loop on that number, putting your input request inside. Of course, you'll need to check that return and process as well, so build a routine that does all this and call it in the loop.

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

답변 (1개)

Jos (10584)
Jos (10584) 2014년 3월 19일

0 개 추천

N = str2double(inputdlg('How many inputs','N'))
if ~isempty(N) && ~isnan(N) && N > 0 && N < 10 % sanity check!
prompts = cellstr(strcat('Information about layer #',num2str((1:N).'))) ;
V = inputdlg(prompts, 'Information')
% V is a cell array of N strings
end

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

2014년 3월 19일

답변:

2014년 3월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by