How to concatenate strings in a loop?

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?

Answers


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);


Need Your Help

just got done with an image upload php mysql

php forms file-upload

I just had it working, then I thought I was done and it stopped working. if the file is not an image, I'm trying to get it to kick out an error. here is the piece im talking about. any help would be

What other languages have features and/or libraries similar to Perl's format?

ruby perl format

I may be in the minority here, but I very much enjoy Perl's formats. I especially like being able to wrap a long piece of text within a column ("~~ ^<<<<<<<<<<<&l...