MATLAB: Loop over a list of numbers, Part 2

loopMATLAB

In a previous question, I have asked
I would like to run a loop over a list of numbers like {3,6,18}. Please advise.
The answer I got is
numlist = {3,6,18};
for k1 = 1:length(numlist)
fprintf('Number at position %d = %6.2f\n', k1, numlist{k1})
end
Now I want to have the legend indexed by numbers in numlist. Currently it has
lgndcell = regexp(sprintf('%2d Price (Mean: %.3f, Std: %.3f)\n', [[6 12 24]; mean(Output); std(Output)]), '\n', 'split');
legend(lgndcell(1:end-1))
I want to replace [6 12 24] part by entries in numlist. Please advise.

Best Answer

I tested this with the previous code to be certain it works. It does:
lgndcell = regexp(sprintf('%2d Bidders (Mean: %.2f, Std: %.2f)\n', [numlist{:}; mean(OutputSpacing); std(OutputSpacing)]), '\n', 'split');
legend(lgndcell(1:end-1))