Creating cell arrays of strings using the {}
operator is
discouraged. To concatenate strings into a string array, use square brackets
instead. Then, you can index into, manipulate, and compare the text in the
string array.
For example, suppose you have a string array that contains three strings. You
can find the strings that start with the letter S
in
str
with the startsWith
function.
startsWith(["Skylab" "Skylab B" "ISS"], "S")
Using the startsWith
function with a cell array of
strings returns an error.
Replace the braces surrounding the strings with square brackets.
For example, replace code such as {"Skylab" "Skylab B"
"ISS"}
with ["Skylab" "Skylab B" "ISS"]
.