Is it possible to create a variable like list of numbers from other matrix?
14 views (last 30 days)
Show older comments
Kiryl Zhaliazka
on 8 Mar 2022
Answered: the cyclist
on 8 Mar 2022
For example, I have random matrix 10*10, and I want to create array of numbers that my matrix has, and if some of numbers repeat at matrix several times, show this numbers in my "list" ones.
Thank you!
0 Comments
Accepted Answer
More Answers (1)
the cyclist
on 8 Mar 2022
Is this what you mean? I'll illustrate with a smaller matrix.
M = [ 2 2;
3 5;
7 7;
9 11;
13 13];
[numberOfOccurrences, uniqueValues] = histcounts(M(:)',[unique(M(:))' Inf])
(You can obviously get rid of the Inf value. It's necessary because of the way that histcounts does the binning.)
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!