计算字符串出现次数并绘制直方图

问题描述:

有没有一种简单的方法可以从像下面这样的单元格数组中创建直方图?连续的条形图之间的间距应完全相同,并且x轴的标签应为以下垂直方向上变量的对应名称.

Is there any straightforward way to create a histogram from a cell array like the one below? The spacing between the consecutive bars should be exactly the same and the labels of the x-axis should be the corresponding names of the variables below in a vertical orientation.

'w464'
'w462'
'w461'
'w464'
'w461'
'w463'
'w466'
'w461'

我也想知道一种更好的方法.首先,我以回旋方式使用了 countmember 来绘制此类数据. IE.如果您发布的数据名为A

I would like to know a better way, as well. Fwiw, I have used countmember in a roundabout way to plot data like this. I.E. if the data you posted was named A

>> B={sort(unique(A)) countmember(sort(unique(A)),A)};
>> bar(B{2});
>> set(gca,'XTickLabel',B{1})