MATLAB: Hi there! I am working on a script that will convert an array with zeros into an array of symbols.

tag:function

So for example let's say i have an array of :
[0,0,0,0,0,0]
With the commands i want to convert it to :
[*,*,*,*,*,*].
I would be really happy if you could help me, i am quite much of a beginner to Matlab. Also, i am currently using Matlab R2013a (I don't know if the version would matter for this question). Thanks already! ^^

Best Answer

'*' isn't an object in MATLAB, so it cannot be stored on its own. You need to store it as a character in MATLAB. Instead of creating an array of zeros using zeros(1,5), you can directly use repmat to a cell array with '*' as its element
A = repmat({'*'}, 1, 10)
or
A = repmat('*', 1, 10)
However, in this case, as Walter mentioned, they will be concatenated as a char array.
Related Question