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 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/549159-finding-the-number-of-occurance-of-each-value-in-the-each-columns-of-a-matrix#comment_900177
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/549159-finding-the-number-of-occurance-of-each-value-in-the-each-columns-of-a-matrix#comment_900177
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/549159-finding-the-number-of-occurance-of-each-value-in-the-each-columns-of-a-matrix#comment_900207
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/549159-finding-the-number-of-occurance-of-each-value-in-the-each-columns-of-a-matrix#comment_900207
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/549159-finding-the-number-of-occurance-of-each-value-in-the-each-columns-of-a-matrix#comment_900288
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/549159-finding-the-number-of-occurance-of-each-value-in-the-each-columns-of-a-matrix#comment_900288
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/549159-finding-the-number-of-occurance-of-each-value-in-the-each-columns-of-a-matrix#comment_900396
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/549159-finding-the-number-of-occurance-of-each-value-in-the-each-columns-of-a-matrix#comment_900396
Sign in to comment.