Is it possibe to create an array of strings in MATLAB within a for loop?
For example,
for i=1:10
Names(i)=\'Sample Text\';
end
I do
You can create a character array that does this via a loop:
>> for i=1:10 Names(i,:)='Sample Text'; end >> Names Names = Sample Text Sample Text Sample Text Sample Text Sample Text Sample Text Sample Text Sample Text Sample Text Sample Text
However, this would be better implemented using REPMAT:
>> Names = repmat('Sample Text', 10, 1)
Names =
Sample Text
Sample Text
Sample Text
Sample Text
Sample Text
Sample Text
Sample Text
Sample Text
Sample Text
Sample Text