Finding the number of occurance of each value in the each columns of a matrix.
1 次查看(过去 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!