MATLAB: Ascending table column labels

labelsMATLABtable

Hello all,
I've got a table which contains 38 column's, each representing one cycle. I want to label them "cycle 1", "cycle 2", etc.
I tried something like this, but this doesn't work. Any help would be appreciated, thank you!
colnames = "Cycle" + 1:size(matrix,2);
table = array2table(matrix,'VariableNames', colnames);

Best Answer

Use the compose function (R2016b and later versions):
colnames = compose("Cycle %d", 1:size(matrix,2));
Alternatively, use the sprintfc (undocumented) function:
colnames = sprintfc("Cycle %d", 1:size(matrix,2));
No loop necessary.