我将函数 histcnd 应用于大小为 744x2 的矩阵。此函数计算某些边缘内的值的频率。例如,我想将边缘设置为 5 个值的组,但我似乎无法做到。
该函数的语法是 histcnd(X,edges),其中边的长度必须与 X 的列数相同。如何将“边”定义为 2 列向量,以便它将每个值分组每 5 个值列?
使用这样的东西怎么样:
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);
如果您对数据有所了解,您可能会以更智能的方式选择每个轴的最小/最大值。