0 0 1
0 0 0
Compare a string array to a character vector. As long as one of the variables is a string
array, you can make the comparison.
chr = 'Gemini';
TF = (str1 == chr)
TF = 2x3 logical array
0 1 0
0 0 0
Index into str1 with TF to extract the string elements that matched Gemini. You can use
logical arrays to index into an array.
str1(TF)
ans =
"Gemini"
Compare for inequality using the ~= operator. Index into str1 to extract the elements
that do not match 'Gemini'.
TF = (str1 ~= chr)
TF = 2x3 logical array
1 0 1
1 1 1
str1(TF)
ans = 5x1 string array
"Mercury"
"Skylab"
"Skylab B"
"Apollo"
"International Space Station"
6 Characters and Strings