Finding the number of occurance of each value in the each columns of a matrix.

2 ビュー (過去 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 件のコメント
Ashwani Kumar MAlviya
Ashwani Kumar MAlviya 2020 年 6 月 16 日
Dear KSSV
unique result is not somthing I am looking for. It is shorting the columns. Can you please explain me more?
dpb
dpb 2020 年 6 月 16 日
Read about histcounts()

サインインしてコメントする。

採用された回答

Divya Gaddipati
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 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by