私は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]
は今、私はどのようにインデックスを知っている最高の発生 を持っていた手紙を取得する必要がありますか?
function maxの最初の出力は何ですか? – pac
これは最大値です。 – Oli