How to have a user input prompt more user inputs?
1 view (last 30 days)
Show older comments
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 Comment
dpb
on 19 Mar 2014
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.
Answers (1)
Jos (10584)
on 19 Mar 2014
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
0 Comments
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!