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 Comment

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.

Sign in to comment.

Answers (1)

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

Tags

Asked:

on 19 Mar 2014

Answered:

on 19 Mar 2014

Community Treasure Hunt

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

Start Hunting!