Products & Services Solutions Academia Support User Community Company

Learn more about Statistics Toolbox   

unique - Class: dataset

Unique observations in dataset array

Syntax

B = unique(A)
B = unique(A,vars)
[B,i,j] = unique(A)
[...] = unique(A,vars,'first')

Description

B = unique(A) returns a copy of the dataset A that contains only the sorted unique observations. A must contain only variables whose class has a unique method, including:

For a variable with multiple columns, its class's unique method must support the 'rows' flag.

B = unique(A,vars) returns a dataset that contains only one observation for each unique combination of values for the variables in A specified in vars. vars is a positive integer, a vector of positive integers, a variable name, a cell array containing one or more variable names, or a logical vector. B includes all variables from A. The values in B for the variables not specified in vars are taken from the last occurrence among observations in A with each unique combination of values for the variables specified in vars.

[B,i,j] = unique(A) also returns index vectors i and j such that B = A(i,:) and A = B(j,:).

[...] = unique(A,vars,'first') returns the vector i to index the first occurrence of each unique observation in A. unique(A,vars,'last'), the default, returns the vector i to index the last occurrence. Specify vars as [] to use the default value of all variables.

See Also

dataset, set, subsasgn

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS