rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
face_in_matrix.m
1 function ind = face_in_matrix(face, matrix)
2 % function ind = face_in_matrix(face, matrix)
3 %
4 % function searching for the 4x1 vector face in the columns of the
5 % 4xn matrix by all cyclical permutations and reflection
6 % if found, the column-indices are returned in ind, otherwise it is empty
7 
8 % Bernard Haasdonk 13.3.2006
9 
10 matmat = repmat (matrix, 1,8); % =>
11 ff = repmat(face(:),1,size(matrix,2));
12 faceface = [ff, ff([2 3 4 1],:), ff([3 4 1 2],:), ...
13  ff([4 1 2 3],:), ff([4 3 2 1],:), ff([3 2 1 4],:), ...
14  ff([2 1 4 3],:), ff([1 4 3 2],:)];
15 s = sum(abs(matmat-faceface));
16 i = find(s==0);
17 ind = [];
18 if ~isempty(i)
19  ind = mod(i-1,size(matrix,2))+1;
20 end;
21 
22 
23 % TO BE ADJUSTED TO NEW SYNTAX
24 %| \docupdate