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
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)
2014년 3월 19일
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에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!