searchsortingfindoctavecell-array

How do you sort and efficiently find elements in a cell array (of strings) in Octave?


Is there built-in functionality for this?


Solution

  • Yes check this: http://www.obihiro.ac.jp/~suzukim/masuda/octave/html3/octave_36.html#SEC75

    a = ["hello"; "world"];
    c = cellstr (a)
         ⇒ c =
             {
               [1,1] = hello
               [2,1] = world
             }
    >>> cellidx(c, 'hello')
    ans =  1
    
    >>> cellidx(c, 'world')
    ans =  2