Extracting histogram each row of matrix

6 次查看(过去 30 天)
Hi Everyone,
I have a matrix name as input:
A = [0 4; 0 -5; 0 -1; 0 -1; 2 -1; 3 3; 2 4; 4 0; 0 1; 0 -2; 0 -1; 0 -1; 0 -1;2 -1;2 -1;3 3; 2 4; 4 0];
I want to extract histogram analysis each row of "input" according the other rows. I actually wonder frequency of each row according to other rows. How can i do that without a loop?

回答(2 个)

Mohsin Shah
Mohsin Shah 2019-5-15
编辑:madhan ravi 2019-5-15
I hope this will solve your problem.
A = [0 4; 0 -5; 0 -1; 0 -1; 2 -1; 3 3; 2 4; 4 0; 0 1; 0 -2; 0 -1; 0 -1; 0 -1;2 -1;2 -1;3 3; 2 4; 4 0];
[Mu,ia,ic] = unique(A, 'rows', 'stable');
% Unique Values By Row, Retaining Original Order
h = accumarray(ic, 1); % Count Occurrences
maph = h(ic); % Map Occurrences To ‘ic’ Values
Result = [A, maph]

gonzalo Mier
gonzalo Mier 2019-5-11
  1 个评论
cem
cem 2019-5-12
I actually read histogram and I could not understand how am I calculate histogram of two element according to others.

请先登录,再进行评论。

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by