how many times matrix elements are repeated

Dear all! I am looking for a fast algorithm to count how many times elements in huge matrices are repeated. Example: Input{1 0 2}{1 1 2}, answer would be: 1 = 3, 2 = 2.
I will extremly appreciate your help!

Answers (1)

A = [1 0 2; 1 1 2]
A = 2×3
1 0 2 1 1 2
nnz(A == 1)
ans = 3
nnz(A == 2)
ans = 2

Asked:

on 24 Oct 2011

Answered:

on 28 Dec 2021

Community Treasure Hunt

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

Start Hunting!