MATLAB: How to creat a empty string

empty stringstring

Hi,
I need to add string to a string array, but I cannot get the results with length of 3 (like the matrix in the following code), but 4 with a empty string("") for first element. How can I create a empty string? or any alternertive approach for this purpose? Thank you very much
Example:
% for matrix
a = [];
for i = 1:3
a(end+1) = 1;
end
results: a = 1 1 1
% for string
a = string(); % a = strings; a = ""; works same
for i = 1:3
a(end+1) = "1";
end
results: a =
1×4 string array
"" "1" "1" "1"

Best Answer

% for string
a = string([]);
for i = 1:3
a(end+1) = "1";
end
Related Question