Borrar filtros
Borrar filtros

Count unique values in an array

6 visualizaciones (últimos 30 días)
Ana
Ana el 29 de Mzo. de 2014
Comentada: Ana el 30 de Mzo. de 2014
Hello,
I have the following set of data
I need to count how many times the values in column 3 appear. So, for instance: SABC appears 4 times. BTFG appears 20 times. GCBK appears 7 times and so on.
Afterwards I would want to erase the rows for the variables that appear less than 100 times. Is there an efficient way to do this? I'm new at matlab. Thank you so much in advance.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 29 de Mzo. de 2014
Editada: Azzi Abdelmalek el 29 de Mzo. de 2014
If M is your cell array Try this,
c3=M(:,3)
[ii,jj,kk]=unique(c3)
f=histc(kk,1:numel(jj)); % Frequencies corresponding to ii
idx=f<100
idx1=ismember(c3,ii(idx))
M(idx1,:)=[]
  1 comentario
Ana
Ana el 30 de Mzo. de 2014
Thank you, it works perfectly!!

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 29 de Mzo. de 2014
hint: how many outputs can unique() have?

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by