counting the values and variables
조회 수: 10 (최근 30일)
이전 댓글 표시
I have a dataset 50x62
for example
S=['F' 'D' 'C' 'D' 'C';'C' 'C' 'F' 'D' 'F']
these variables are my output from one operation,now i want to count the number of variables
here i have 2 rows and number of variable is 3
so i need as
F D C
1 2 2
2 1 2
PLEASE HELP
채택된 답변
Daniel Shub
2012년 3월 25일
What about a nice loop:
S=['F' 'D' 'C' 'D' 'C';'C' 'C' 'F' 'D' 'F'];
x = sort(unique(S));
fprintf('%c\t', x')
fprintf('\n')
for ii = 1:size(S, 1)
for jj = 1:length(x)
temp(jj) = length(find(S(ii, :) == x(jj)));
end
fprintf('%d\t', temp);
fprintf('\n')
end
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!