Is it possible to create a variable like list of numbers from other matrix?
14 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(1 个)
the cyclist
2022-3-8
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!