我試過Matlab和網絡來找到答案,但徒勞無功,所以我需要你的幫助 我已經使用下面的代碼來查找數組中的字母出現次數;找到哪個字母有最大的出現
characterCell = {'a' 'b' 'b' 'a' 'b' 'd' 'c' 'c'}; %# Sample cell array
matchCell = {'a' 'b' 'c' 'd' 'e'}; %# Letters to count
[~,index] = ismember(characterCell,matchCell); %# Find indices in matchCell
counts = accumarray(index(:),1,[numel(matchCell) 1]); %# Accumulate indices
results = [matchCell(:) num2cell(counts)] `
結果=
'a' [2] 'b' [3] 'c' [2] 'd' [1] 'e' [0]
現在我需要得到這封信具有最高發生 如何知道索引?
函數max的第一個輸出是什麼? – pac 2012-02-24 21:26:01
這是最大值。 – Oli 2012-02-24 21:26:25