我将函数histcnd应用于一个大小为744x2的矩阵。此函数计算特定边缘内的值的频率。例如,我想将边缘设置为5个值的组,但我似乎无法这样做。
函数的语法是histcnd( X,edges),其中边的长度必须与X的列数相同。我如何将‘edge’定义为2列向量,以便它每5个值对每列的值进行分组?
发布于 2012-01-27 23:55:06
使用下面这样的代码怎么样:
X = randn(744,2);
[a,b] = size(X);
edges = num2cell([linspace(min(X(1,:)),max(X(1,:)),a/5); linspace(min(X(2,:)), max(X(2,:)),a/5)],2);
# not sure if it's the same histcnd, the one I found wants edges to be a cell array
H = histcnd(X, edges);如果您对数据有所了解,您可能会以更智能的方式选择每个轴的最小/最大值。
https://stackoverflow.com/questions/9035832
复制相似问题