In MATLAB, I would like to iteratively add string to array s, and I initialized s by s = []. However, when I run the code below
s = [];
s(end+1) = "a";
s(end+1) = "b";
it results in
>> s
s =
NaN NaN
Does anyone know the reason behind and any workaround for this issue?
However, when I have already "" in s, i.e., s = [""], then all the following elements can added to s without problem:
s = [""];
s(end+1) = "a";
s(end+1) = "b";
gives
s =
1×3 string array
"" "a" "b"