4

I'd like to create an inputdlg with various lines with similar names like Test 1, Test 2, Test 3 and so. So I'm looking for some way to concatenate strings in a for loop. I tried something like:

 formatSpec = '''Test %d'',';
    a = sprintf(formatSpec,1);
    for i = 2:numtest
        a = strcat(a,sprintf(formatSpec,i));
    end

but it's not working for inputdlg. How do I do this?

1 Answer 1

4

This may be what you want:

for i = 1:10
    line_name = sprintf('Test %d', i);
    prompt{i} = line_name;
end
input_result = inputdlg(prompt);

Enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.