Hey every one , a small question :)
how can i determine the umber of occrancy in big arraw (481* 81)
I give a little exemple , with my primary script for that :)
Any help please :)
tableau_string=textdata
nb_rows=length(tableau_string(:,1)) %481 nb_col=length(tableau_string(1,:)) %80
count=0
for s=1:1:nb_rows
for i=1:1:nb_rows for j=1:1:nb_col if tableau_string(i,j)== tableau_string(s,1) count=count+1 end end end
tableau_string(s,2)= count
end

댓글 수: 1

Firas
Firas 2015년 1월 12일
편집: Firas 2015년 1월 12일
??? Undefined function or method 'eq' for input arguments of type 'cell'.
Error in ==> Untitled at 14 if tableau_string(i,j)== tableau_string(s,1)

댓글을 달려면 로그인하십시오.

 채택된 답변

Guillaume
Guillaume 2015년 1월 12일

0 개 추천

One way of doing it:
tableau_string = {'3.5' 'alain' '3.5' 'alain'; 'alain' '' 'alain' 'test'; '' 'test' '' 'test'; '5' 'test' '5' 'test'};
[strings, ~, position] = unique(tableau_string(:));
count = accumarray(position, ones(1, numel(tableau_string)));
stringcounts = [strings num2cell(count)] %if you want it all in a cell array
You could use histc or hiscounts instead of accumarray for the same result.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

2015년 1월 12일

댓글:

2015년 1월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by