From help-request at octave dot org Mon Jan 24 20:04:16 2005 Subject: Iterating over cell arrays From: Hamish Allan To: help at octave dot org Date: Tue, 25 Jan 2005 02:06:48 +0000 Hi, I'd like to be able to check for membership in a cell array, e.g.: octave> cell_array = { 'Foo' 'Bar' 'Baz' 'FooBar' }; octave> ismember('Bar', cell_array) ans = 1 1 1 octave> ismember('FooBar', cell_array) ans = 1 1 1 1 1 1 octave> ismember('z', cell_array) % NB if cell_array were a character matrix this would return 'ans = 1' ans = 0 But of course I get: error: binary operator `==' not implemented for `cell' by `cell' operations error: evaluating binary operator `==' near line 67, column 24 [etc.] Because there is no guarantee that cell matrices will be comparable, none are compared. Two queries: 1) Would it be reasonable for ismember() to be designed to behave in the way I describe above? 2) Is there a simpler way to do what I want to do than writing a function to iterate over the members of cell_array? I don't even need the intersection, I just want a true or false test for membership. Many thanks, Hamish ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------