Reputation: 341
How can I employ repmat to produce the vector below;
sysHealthy={'sys';'sys';'sys';'sys';'sys'}
I tried:
A=repmat({'sys'},1,5);
unique_cell = {sprintf('%3s;',A{:})};
but it produces the put below:
{'sys;sys;sys;sys;sys;'}
This output has two problems: first, in doesn't have double quotation above each sys and second, it has an ; at the end of the array. I would like to get something like
sysHealthy={'sys';'sys';'sys';'sys';'sys'}.
Upvotes: 2
Views: 2009
Reputation: 772
Try the following lines --
charLength = 3; repCount = 5;
A=repmat('sys',repCount,1); % Creates a column vector
sysHealthy = mat2cell(A, repmat(1, [1,repCount]),charLength); % Convert them into cell.
Upvotes: 3