MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

You can create a string array with both empty and missing strings. Use the ismissing
function to determine which elements are strings with missing values. Note that the
empty string is not a missing string.


str(1) = "";
str(2) = "Gemini";
str(3) = string(missing)


str = 1x3 string array
"" "Gemini"


ismissing(str)


ans = 1x3 logical array


0 0 1


Compare a missing string to another string. The result is always 0 (false), even when
you compare a missing string to another missing string.


str = string(missing);
str == "Gemini"


ans = logical
0


str == string(missing)


ans = logical
0


Access Elements of String Array


String arrays support array operations such as indexing and reshaping. Use array
indexing to access the first row of str and all the columns.


str = ["Mercury","Gemini","Apollo";
"Skylab","Skylab B","ISS"];
str(1,:)


Create String Arrays
Free download pdf