www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SpecifyDataScaleByColumnExample.m
%% Specify DataScale by Column % Create a set of random 2-D points, and then use |ismembertol| to group % the points into vertical bands that have a similar (within-tolerance) % x-coordinate to a small set of query points, |B|. Use these options with % |ismembertol|: % % * Specify |ByRows| as |true|, since the point coordinates are in the rows % of |A| and |B|. % * Specify |OutputAllIndices| as |true| to return the indices for all % points in |A| that have an x-coordinate within tolerance of the query % points in |B|. % * Specify DataScale as |[1 Inf]| to use an absolute tolerance for the % x-coordinate, while ignoring the y-coordinate. % Copyright 2015 The MathWorks, Inc. A = rand(1000,2); B = [(0:.2:1)',0.5*ones(6,1)]; [LIA,LocAllB] = ismembertol(B, A, 0.1, 'ByRows', true, ... 'OutputAllIndices', true, 'DataScale', [1,Inf]) %% % Plot the points in |A| that are within tolerance of each query point in % |B|. hold on plot(B(:,1),B(:,2),'x') for k = 1:length(LocAllB) plot(A(LocAllB{k},1), A(LocAllB{k},2),'.') end