%% Unique Rows in Table
% Create a table with some repeated data.

Name = {'Fred';'Betty';'Bob';'George';'Jane'};
Age = [38;43;38;40;38];
Height = [71;69;64;67;64];
Weight = [176;163;131;185;131];
A = table(Age,Height,Weight,'RowNames',Name)

%
% Find the unique rows of A. unique returns the rows of A in sorted order by the first variable Age and then by the second variable Height.

C = unique(A)

%
%
% Find the table rows with unique values in the first variable Age. If you only want one table variable to contain unique values, you can use the indices returned by unique to extract those rows from the table.

[C,ia] = unique(A.Age);
B = A(ia,:)

%
% Copyright 2012 The MathWorks, Inc.