我编写了以下可用的Matlab代码。对于相同的点,它需要对不同维度进行两组测量,并从中构建“矩形”直方图。我的目标是获得数组res
,其中res(i,j1,j2)
=第一个直方图的bin j1和第二个直方图中的bin j2的点i的测量数。 Voyez plutot:
clear all
nb = 500;
dim1 = 50;
dim2 = 70;
measurement1 = rand(nb,dim1);
measurement2 = rand(nb,dim2);
edges1 = linspace(0,1, 10);
edges2 = linspace(0,1, 6);
res = zeros(nb, length(edges1), length(edges2));
for i = 1:nb
[N1 EDGES1 BIN1] = histcounts(measurement1(i,:), edges1);
[N2 EDGES2 BIN2] = histcounts(measurement2(i,:), edges2);
for j1 = 1:length(edges1)-1
for j2 = 1:length(edges2)-1
res(i,j1,j2) = sum((BIN1 == j1) & (BIN2 == j2));
end
end
end
完全不合情理,特别是环路的三重。谁能建议一个更好的方法呢?提前谢谢!