MATLAB: Sprintf to cell array

sprintf cell-array

How can I make sprintf output a cell array, with a nice vectorized notation?
When I have:
C = {'a','b'}
Output = sprintf('Letter:%s\n',C{:})
It becomes a char of length 18. Simple workaround would be a loop, maybe scan with a separator, or a solution with cellfun and anonymous function should work as well.
But is there not a nice straightforward vectorized solution to this? My first guess would have been something like:
Output{:} = sprintf('Letter:%s\n',C{:})
Which does not work.
Thanx in advance Sven

Best Answer

Read this blog, it shows lots of ways of doing this, and also introduces the fastest method of all (which is undocumented, so use it at your own risk):
EDIT some alternative for strings. Thinking outside the box and is very fast:
strrep(['Letter:%s',10],'%s',{'a','b'})
Much slower:
strcat('Letter:',{'a','b'},char(10))
cellfun(@(s)sprintf('Letter:%s\n',s),{'a','b'},'UniformOutput',false);