how to find the second most repeated value in vector
43 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
mary m
el 25 de Ag. de 2017
Comentada: Ambati Sathvik
el 2 de Jul. de 2020
how to find the second most repeated value in vector x=[1 2 2 3 5 5 5] i use (mode ) to find the most repeated and frequency [m,f]=mode(x) m=5 the number repeated f=3 the freq.
now,i want to find the second repeated, can help me please
0 comentarios
Respuesta aceptada
Más respuestas (4)
Walter Roberson
el 25 de Ag. de 2017
Delete all the copies of m out of x and take the mode again.
1 comentario
Apoorva Srivastava
el 16 de Jun. de 2019
Editada: Apoorva Srivastava
el 16 de Jun. de 2019
% For a vector x:
mode(x(find(x ~= mode(x))))
% In general, if x is a matrix (valid from R2018b onwards)
mode(x(find(x ~= mode(x, 'all'))), 'all')
Andrei Bobrov
el 25 de Ag. de 2017
[g,v] = findgroups(x);
ii = accumarray(g(:),1);
jj = find(ii > 1);
out = [v(jj(2)), ii(jj(2))]
0 comentarios
alexander Mcghee
el 17 de Sept. de 2019
X = [1 1 1 1 1 5 5 5] ;
m = mode(X) % -> m=1
X(X==m) = NaN ;
m = mode(X) % -> m=5
Ver también
Categorías
Más información sobre Detection 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!