1

Given a cell with string values I would like to count how many different values are stored in it. The following ae the example values:

A(1, 1) = 'DA4590162D037A78D96557AA886ADF9715B79C75';
A(2, 1) = 'AFAB19476C2CEEEE101FFA45FD207BA8B6185B29';
A(3, 1) = '99C1F96461BC870574D002034F001BA3F96A9AB5';
...
A(8, 1) = '99C1F96461BC870574D002034F001BA3F96A9AB5';
A(9, 1) = '4B7F0F39C1192D12E6C798143981048D01CDDDD3';
...

There are approximately 3M rows. Does anyone know the way to calculate how many unique values are stored in the structure?

Thank You!

Shai
  • 111,146
  • 38
  • 238
  • 371
Niko Gamulin
  • 66,025
  • 95
  • 221
  • 286

1 Answers1

5

B = UNIQUE(A) for the array A returns the same values as in A but with no repetitions. B will also be sorted. A can be a cell array of strings.

So

U = unique(A, 'rows'); %because each string is one row
numUnique = length(U)
Shai
  • 111,146
  • 38
  • 238
  • 371
Marc
  • 5,315
  • 5
  • 30
  • 36