1 function [Vx, Vy, lambda] = velocity_matrixfile_extract(fullfn,X,Y)
2 %
function [Vx, Vy, lambda] = velocity_matrixfile_extract(fullfn,X,Y)
4 %
function extracting the velocities from the given file in the
5 % points X and Y. A search is performed in
case of partial access.
6 % So
this function is expensive.
9 V = cache(
'load',fullfn);
11 % find integer indices such that V.X(j)==X(i) and V.Y(j) = Y(i)
12 % if whole flux-matrix is requested
14 if ~isempty(X) % otherwise size 0/0 => 0/1 !!!
18 if isequal(X,V.X(:)) && isequal(Y,V.Y(:))
25 % otherwise search corresponding matrix entries
26 %% the following gives memory problem in 'large point set' requests
28 % VXX = repmat(V.X(:)',length(X),1);
29 % VYY = repmat(V.Y(:)',length(X),1);
30 % XX = repmat(X(:),1,length(V.X));
31 % YY = repmat(Y(:),1,length(V.X));
32 % [i,j] = find(VXX==XX & VYY==YY);
33 % should give one entry for each i!!
34 % if ~isequal(sort(i),(1:length(X))')
35 % error('requested points not or multiple times in matrix!');
38 % so mixture: blockwise approach as above
40 % % compute optimal cut-size if required
42 % cutsize = ceil(5000000/length(V.X));
43 % ncuts = ceil(n1/cutsize)
45 % ind1 = (1+(c-1)*cutsize):min(n1, c*cutsize);
47 % VXX = repmat(V.X(:)',length(ind1),1);
48 % VYY = repmat(V.Y(:)',length(ind1),1);
49 % XX = repmat(X(ind1),1,length(V.X));
50 % YY = repmat(Y(ind1),1,length(V.X));
51 % [ipart,jpart] = find(VXX==XX & VYY==YY);
53 % i = [i; ipart(:)+(c-1)*cutsize];
56 [i,j] = find_corresp([X(:)';Y(:)'],[V.X(:)';V.Y(:)']);
57 % remove occasional
double find-results (inner edges)
61 diff = si(2:end)-si(1:end-1);
62 k = find(diff~=0); % => si(k+1)~=si(k)
65 %should give one entry for each i!!
66 if ~isequal(sort(i),(1:length(X))')
67 error('requested points not or multiple times in matrix!');
70 % i(k) is the linear index of the point k in the list X / Y
71 % j(k) is the linear index of the point k in the list V.X / V.Y
72 Vx = NaN*ones(size(X));
73 Vy = NaN*ones(size(X));