MATLAB Answers

0

Extracting histogram each row of matrix

cem 님이 질문을 제출함. 11 May 2019
최근 활동 madhan ravi 님이 편집함. 15 May 2019
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

Don‘t name your variable input!!!
I am also looking for the same solution.

로그인 to comment.

답변 수: 2

Answer by gonzalo Mier on 11 May 2019

  댓글 수: 1

cem
on 12 May 2019
I actually read histogram and I could not understand how am I calculate histogram of two element according to others.

로그인 to comment.


Answer by Mohsin Shah on 15 May 2019
Edited by madhan ravi
on 15 May 2019

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]

  댓글 수: 0

로그인 to comment.



Translated by