Mercurial > hg > ltpda
diff m-toolbox/classes/+utils/@helper/ismember.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/+utils/@helper/ismember.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,25 @@ +% ISMEMBER a simpler version that just checks if the given string(s) is/are in the +% given cell-array. +% +% res = ismember(string, cell2) +% res = ismember(cell1, cell2) +% +% M Hewitson +% +% $Id: ismember.m,v 1.1 2009/08/05 12:12:23 hewitson Exp $ +% +function res = ismember(s, c) + + if ischar(s) + res = any(strcmp(s, c)); + elseif iscell(s) + res = false(size(s)); + for kk=1:numel(s) + if any(strcmp(s{kk}, c)) + res(kk) = true; + end + end + else + error('### Only works for string or cell inputs.'); + end +end \ No newline at end of file