www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SpecifyDataScaleByColumnUniqueExample.m
%% Specify DataScale by Column % Create a set of random 2-D points, then use |uniquetol| to group the % points into vertical bands that have a similar (within tolerance) % x-coordinate. Use these options with |uniquetol|: % % * Specify |ByRows| as |true| since the point coordinates are in the rows % of |A|. % * Specify |OutputAllIndices| as |true| to return the indices for all % points that have an x-coordinate within tolerance of each other. % * 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); DS = [1 Inf]; [C,IA] = uniquetol(A, 0.1, 'ByRows', true, ... 'OutputAllIndices', true, 'DataScale', DS); %% % Plot the points and average value for each band. hold on for k = 1:length(IA) plot(A(IA{k},1), A(IA{k},2), '.') meanAi = mean(A(IA{k},:)); plot(meanAi(1), meanAi(2), 'xr') end