18 lines
424 B
Matlab
18 lines
424 B
Matlab
function [col,row,pln] = find_chunk(xq,x,ibeg,iend,a,b,periodic)
|
|
|
|
if periodic
|
|
xq = mod(xq-a,b-a)+a;
|
|
elseif any(xq<a || xq>b)
|
|
error('Query points must be located inside domain.');
|
|
end
|
|
|
|
x = reshape(x,[],1);
|
|
xq = reshape(xq,1,[]);
|
|
[~,ii] = min(abs(bsxfun(@minus,x,xq)));
|
|
|
|
nxq = numel(xq);
|
|
col = zeros(1,nxq);
|
|
for iq=1:nxq
|
|
col(iq) = find(ii(iq)>=ibeg & ii(iq)<=iend,1,'first');
|
|
end
|
|
end |