keysData = {'a', 'b', 'c', 'e', 'g'}; valuesData = [1,3,4,5,8];
map = containers.Map(keysData,valuesData);
bar(cell2mat(map.values));
k = keys(map);
set(gca, 'XTick', 1:length(k));
set(gca, 'XTickLabel', k);
keySet = cell2mat(map.keys);
maxFrequency = 0;
maxKey = '';
for i = 1:numel(keySet)
iThValue = map(keySet(i));
if iThValue >= maxFrequency
maxFrequency = iThValue;
maxKey = keySet(i);
end
end
maxKey
maxFrequency
1 Comment
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/611701-using-container-map-to-get-values-and-to-draw-histogram#comment_1054216
Direct link to this comment
https://it.mathworks.com/matlabcentral/answers/611701-using-container-map-to-get-values-and-to-draw-histogram#comment_1054216
Sign in to comment.