MATLAB: How to concatenate an array of numbers without for loop

MATLABundocumented

Hi, I have an array of integer numbers A = [1, 2, 3]. I would like to concatenate the numbers for use in SQL statement like '(1, 2, 3)'. How to do that without a for loop? Thanks.

Best Answer

>> A = [1,2,3];
>> str = sprintf(', %d',A);
>> str = sprintf('(%s)',str(3:end))
str = (1, 2, 3)