Finding the number of occurance of each value in the each columns of a matrix.
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi there
I have a doubt in calculating frequency of repeating value.
Lets say I have a matrix 'FCL21' of m X n. n if fixed lets say 12 but m may vary according to filter in excel data.
the elements of matrix may have values 1 to 9 and 1/2 to 1/9 .
For further calculations, I need to create an matrix containing frequency of each value.
I used
XFCL21 = [sum(FCL21==1);sum(FCL21==2);sum(FCL21==3);sum(FCL21==4);sum(FCL21==5); ...
sum(FCL21==6);sum(FCL21==7);sum(FCL21==8);sum(FCL21==9); ...
sum(FCL21==1./2);sum(FCL21==1./3);sum(FCL21==1./4);sum(FCL21==1./5); ...
sum(FCL21==1./6);sum(FCL21==1./7);sum(FCL21==1./8);sum(FCL21==1./9);];
It is working well for m >1. But if in some cases m = 1, It is giving me the counting from the row. that i dont need.
It suppose to give me the counting from columns only. If m = 1 and and an element have value 3 in first row and first column then in XFCL21 should
1 at 3rd row 1st column and remaining element of the column should be 0.
Please suggest me some better ways to overcome this problem.
Thanks in advance.
Regards
Ashwani
댓글 수: 4
채택된 답변
Divya Gaddipati
2020년 6월 25일
A similar question has already been asked and answered by the community which could be of relevance to you.
You can refer to the below link:
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!