rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
find_vector.m
1 function ind = find_vector(vec, mat, epsilon)
2 %function ind = find_vector(vec, mat[, epsilon])
3 %
4 % find a vector in a matrix. If vec is a row vector, rows of mat are
5 % searched, if vec is a column, columns of mat are searched.
6 % equality is decided by l2-error being less than epsilon. epsilon can be
7 % ommited, is default 1e-6
8 
9 % Bernard Haasdonk 29.3.2007
10 
11 % if row vector, transpose the problem
12 
13  if nargin < 3
14  epsilon = 1e-6;
15  end;
16 
17  if size(vec,1) == 1
18  vec = vec';
19  mat = mat';
20  end;
21 
22  vvec = repmat(vec,1,size(mat,2));
23  diff = sqrt(sum((vvec-mat).^2));
24  ind = find(diff<epsilon);
25 
26 
27 % TO BE ADJUSTED TO NEW SYNTAX
28 %| \docupdate