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
Another solution to this old question is the new container string array
, introduced in Matlab 2016b. From what I read in the official Matlab docs, this container resembles a cell-array and most of the array-related functions should work out of the box. For your case, new solution would be:
a=repmat('Some text', 10, 1);
This solution resembles a Rich C's solution applied to string array.