| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Statistics Toolbox |
| Contents | Index |
| Learn more about Statistics Toolbox |
Unique observations in dataset array
B = unique(A)
B = unique(A,vars)
[B,i,j] = unique(A)
[...] = unique(A,vars,'first')
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:
numeric
character
logical
categorical
cell arrays of strings
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.
![]() | undeflabel property (categorical) | units property (dataset) | ![]() |

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 |