You are here: Symbol Reference > Statistics Namespace > Functions > Statistics.Unique Function
Stats Master VCL
ContentsIndex
PreviousUpNext
Statistics.Unique Function

Finds the unique elements in vector/matrix.

Pascal
procedure Unique(const Src: TMtxVec; const Dst: TVec; const Counts: TVecInt = nil);
Parameters 
Description 
Src 
Defines data unique elements search. 
Dst 
Returns unique elements. Size and TMtxVec.Complex properties of Dst are adjusted automatically. 
Counts 
If specifed, stores the count of each unique element in dataset. 

Finds and sorts the unique elements in Src vector/matrix array. Sorted values are returned in Dst vector. An exception is raised if Src is Complex. Length and Complex properties of Dst vector are adjusted automatically.

Collect unique elements from matrix.

Uses MtxExpr, Statistics;
procedure Example;
var m1: Matrix;
  uvec: Vector;
begin
  m1.SetIt(4,3,false,
    [ 1,2,3,
      4,2,1,
      3,2,3,
      3,3,1]);
  Unique(m1,uvec);
  // uvec elements are [1,2,3,4]
end;
#include "MtxExpr.hpp"
#include "Math387.hpp"
#include "Statistics.hpp"
void __fastcall Example()
{
  sMatrix m1;
  sVector uvec;

  m1.SetIt(4,3,false,OPENARRAY(double,(1,2,3,
                                      4,2,1,
                                      3,2,3,
                                      3,3,1)));
  Unique(m1,uvec);
  // uvec elements are [1,2,3,4]
}
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!