简体   繁体   English

MATLAB-装箱数据

[英]MATLAB - Binning Data

I have a large data set and I'm trying to bin the data in increments of 100. I know how to bin data in 100 equal sized bins, but I haven't had any luck specifying a range I would like the data binned in. Anyone have any tips on how to do this? 我有一个很大的数据集,我试图以100为增量对数据进行装箱。我知道如何将数据装在100个相等大小的箱中,但是我没有运气指定要对数据进行装箱的范围任何人都对如何执行此操作有任何提示? I'd also like to be able to label the bins instead of just having bin 1,2,3, etc... 我还希望能够标记垃圾箱,而不只是具有垃圾箱1,2,3等。

Thanks 谢谢

discretize was written for this. discretize是为此写的。 You can specify edges directly. 您可以直接指定边。 From mathworks: 从mathworks:

X = 1:2:21;
edges = primes(21);
Y = discretize(X,edges)

edit: I believe you can reach the same result using histcounts : 编辑:我相信您可以使用histcounts达到相同的结果:

[N,edges] = histcounts(X,edges)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM