findout the repeating element and the no of time of repeated in a matrix

1 次查看(过去 30 天)
i do have a matrix
A=[1,2,3,4,5,5,6,7,8,8,8, 9]
how can i find the repeating values and the no of times it is repeated. answer i expected is
repeatvalues=[5, 8]
Nooftimerepeated=[2,3]

回答(1 个)

Andrei Bobrov
Andrei Bobrov 2015-5-26
编辑:Andrei Bobrov 2015-5-26
A=[1,2,3,4,5,5,6,7,8,8,8, 9]
a = unique(A);
b = histc(A,a);
t = b > 1;
repeatvalues = a(t);
Nooftimerepeated = b(t);

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by