MatrixBerryCore
ismembercellstr.m
Go to the documentation of this file.
1 function [isThereVec,indLocVec]=ismembercellstr(leftList,rightList,isHigherIndexUsed)
2 if nargin==2
3  isHigherIndexUsed=false;
4 end
5 %
6 nRightElems=numel(rightList);
7 nLeftElems=numel(leftList);
8 %
9 if ischar(leftList)
10  if ischar(rightList)
11  isThereVec=strcmp(leftList,rightList);
12  indLocVec=double(isThereVec);
13  else
14  isThereVec=false;
15  indLocVec=0;
16  if isHigherIndexUsed
17  for iRightElem=1:nRightElems
18  if strcmp(leftList,rightList{iRightElem})
19  isThereVec=true;
20  indLocVec=iRightElem;
21  end
22  end
23  else
24  for iRightElem=1:nRightElems
25  if strcmp(leftList,rightList{iRightElem})
26  isThereVec=true;
27  indLocVec=iRightElem;
28  break;
29  end
30  end
31  end
32  end
33 else
34  isThereVec=false(size(leftList));
35  indLocVec=zeros(size(leftList));
36  if ischar(rightList)
37  if isHigherIndexUsed
38  for iLeftElem=1:nLeftElems
39  if strcmp(leftList{iLeftElem},rightList)
40  isThereVec(iLeftElem)=true;
41  indLocVec(iLeftElem)=1;
42  end
43  end
44  else
45  for iLeftElem=1:nLeftElems
46  if strcmp(leftList{iLeftElem},rightList)
47  isThereVec(iLeftElem)=true;
48  indLocVec(iLeftElem)=1;
49  break;
50  end
51  end
52  end
53  else
54  if isHigherIndexUsed
55  for iLeftElem=1:nLeftElems
56  for iRightElem=1:nRightElems
57  if strcmp(leftList{iLeftElem},rightList{iRightElem})
58  isThereVec(iLeftElem)=true;
59  indLocVec(iLeftElem)=iRightElem;
60  end
61  end
62  end
63  else
64  for iLeftElem=1:nLeftElems
65  for iRightElem=1:nRightElems
66  if strcmp(leftList{iLeftElem},rightList{iRightElem})
67  isThereVec(iLeftElem)=true;
68  indLocVec(iLeftElem)=iRightElem;
69  break;
70  end
71  end
72  end
73  end
74  end
75 end
function ismembercellstr(in leftList, in rightList, in isHigherIndexUsed)
ISMEMBERCELLSTR produces the same results as the built-in function "ismember" looking for the higher ...