From: Erik on 13 Apr 2010 06:28 Sounds simple (and might be simple too): Suppose you have a cell array of strings, like cellArray = {'I' 'want' 'this' 'string'} and now want the index of the string 'this'. Just like the find function returns the index of a specified numeric value. I know there is strfind: strfind(cellArray,'this') ans = [] [] [1] [] But how to get this (really fast, need to do this very often with big cellArrays) to an index? Sounds so easy, but somehow I just can't get it working! Very thankful for any help! Thanx! Erik
From: David Young on 13 Apr 2010 06:42 You could try using ismember: [m, i] = ismember('this', cellArray) returns the index in the second argument. I don't know how the speed compares to other methods though.
From: Erik on 13 Apr 2010 06:52 "David Young" <d.s.young.notthisbit(a)sussex.ac.uk> wrote in message <hq1hpt$ns6$1(a)fred.mathworks.com>... > You could try using ismember: > > [m, i] = ismember('this', cellArray) > > returns the index in the second argument. I don't know how the speed compares to other methods though. Perfect! That's just what I wanted. Thank you so very much!
From: Jan Simon on 13 Apr 2010 07:24 Dear Erik! cellArray = {'I' 'want' 'this' 'string'} strcmp(cellArray, 'this') ==> logical([0, 0, 1, 0]) Jan
|
Pages: 1 Prev: Datestr does not give out milliseconds Next: people tracking |