fprintf

% write/print formatted strings from cell array (to stdout fid=1)

C={'A1','A2','A3'}

C

{'A1'} {'A2'} {'A3'}

fprintf(1,'%s\n',C{:})

A1

A2

A3

% print to text file "sampleIDs.txt" (fid - file identifier)

fid = fopen('sampleIDs.txt','w');

fprintf(fid,'%s\n',C{:})

fclose(fid);

% add leading zeros

x = [2, 4, 8, 16, 32, 64, 128]

fprintf(1,'Samples: %03d\n', x ) % print 3 digit numbers

Samples: 002

Samples: 004

Samples: 008

Samples: 016

Samples: 032

Samples: 064

Samples: 128

https://mathworks.com/help/matlab/ref/fprintf.html