www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/DetermineUniqueRowsExample.m
%% Determine Unique Rows % By default, |uniquetol| looks for unique _elements_ that are within % tolerance, but it also can find unique _rows_ of a matrix that are within % tolerance. % % Create a numeric matrix, |A|. Obtain a second matrix, |B|, by % transforming and untransforming |A|. This transformation introduces % round-off differences to |B|. % Copyright 2015 The MathWorks, Inc. A = [0.05 0.11 0.18; 0.18 0.21 0.29; 0.34 0.36 0.41; 0.46 0.52 0.76]; B = log10(10.^A); %% % Use |unique| to find the unique rows in |A| and |B|. The |unique| % function performs exact comparisons and determines that all of the rows % in the concatenated matrix |[A;B]| are unique, even though some of the % rows differ by only a small amount. unique([A;B],'rows') %% % Use |uniquetol| to find the unique rows. |uniquetol| treats rows that are % within tolerance as equal. uniquetol([A;B],'ByRows',true)