The problem is your syntax. When you execute vector = ["ab", "cd", "abc", "cab"] , you do not create a vector of these several lines, you combine them into one line. What you need to do is create an array of row cells:
vector = {"ab", "cd", "abc", "cab"};
And then you can do:
octave-cli-3.8.2> strcmp (vector, "ab") ans = 1 0 0 0
Many other functions will work correctly with an array of row cells, including strfind , which in this case gives you the indices in each cell where the string "ab" is:
octave-cli-3.8.2> strfind (vector, "ab") ans = { [1,1] = 1 [1,2] = [](0x0) [1,3] = 1 [1,4] = 2 }
carandraug
source share