【发布时间】:2015-10-06 23:58:26
【问题描述】:
我有refxy 大小500 x 3 的数据集,其中每一行代表一个位置,使得第一、第二和第三列具有x 坐标、y 坐标和该位置的weight v1。使用以下代码,我将此区域划分为14 x 18 网格,然后我找到每个网格中有多少点输出blockNums_v1。
function gridcounttest
load refxy
x = refxy(:,1);
y = refxy(:,2);
v1 = refxy(:,3);
nBinsX = 14 ;
nBinsY = 18 ;
xg = linspace( 0, 700, nBinsX+1 ) ;
yg = linspace( 0, 900, nBinsY+1 ) ;
nCells = nBinsX * nBinsY ;
xId = sum( bsxfun( @ge, x, xg(1:end-1) ), 2 ) ;
yId = sum( bsxfun( @ge, y, yg(1:end-1) ), 2 ) ;
cellId = nBinsY * (xId - 1) + yId ;
blockNums_v1 = accumarray( cellId, 1, [nCells, 1] )
blockSum_v1 = accumarray( cellId, v1, [nCells, 1] )
blockMean_v2 = accumarray( cellId, v1, [nCells, 1], @mean )
谁能帮我确定每个网格中包含哪些点,可能是行号?例如,如果 10 号网格有 3 个点,分别位于第 23、51 和 432 行。这段代码给出了输出 3,但不是我现在需要得到的 23、51、432 :)
谢谢!!!
【问题讨论】:
-
ge是什么,refxy的数据是什么样的? -
@RobertStettler
ge大于或等于。 de.mathworks.com/help/matlab/ref/ge.html
标签: matlab data-analysis