Mercurial > hg > ltpda
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % ISMEMBER a simpler version that just checks if the given string(s) is/are in the | |
2 % given cell-array. | |
3 % | |
4 % res = ismember(string, cell2) | |
5 % res = ismember(cell1, cell2) | |
6 % | |
7 % M Hewitson | |
8 % | |
9 % $Id: ismember.m,v 1.1 2009/08/05 12:12:23 hewitson Exp $ | |
10 % | |
11 function res = ismember(s, c) | |
12 | |
13 if ischar(s) | |
14 res = any(strcmp(s, c)); | |
15 elseif iscell(s) | |
16 res = false(size(s)); | |
17 for kk=1:numel(s) | |
18 if any(strcmp(s{kk}, c)) | |
19 res(kk) = true; | |
20 end | |
21 end | |
22 else | |
23 error('### Only works for string or cell inputs.'); | |
24 end | |
25 end |