MATLAB: How to create a cell array with constant string entries without for loops.

cell arraycreatestrings

I want to create a cell array of arbitrary size in which each cell contains a particular string, without a for loop.

Best Answer

Here are a couple options. Note that the second option is probably preferable in some respects but can give you trouble if B is already defined.
str = 'mystring';
C = repmat({str},5,6)
B(1:5,1:10) = {str}