计算字符串出现次数并绘制直方图 [英] Count strings occurrences and plot histogram

查看:96
本文介绍了计算字符串出现次数并绘制直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种简单的方法可以从像下面这样的单元格数组中创建直方图?连续的条形图之间的间距应完全相同,并且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})

这篇关于计算字符串出现次数并绘制直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆