在 Matlab 中基于面积求和值

Summing Values based on Area in Matlab

我正在尝试在 Matlab 中编写代码来计算影响区域类型的问题。这是我的数据(加权、x 坐标、y 坐标)的结果:

男=

15072.00 486.00 -292
13269.00 486.00 -292
12843.00 414.00 -267
10969.00 496.00 -287
9907.00  411.00 -274
9718.00  440.00 -265
9233.00  446.00 -253
9138.00  462.00 -275
8830.00  496.00 -257
8632.00  432.00 -253

R=

-13891.00   452.00  -398
-13471.00   461.00  -356
-12035.00   492.00  -329
-11309.00   413.00  -353
-11079.00   467.00  -375
-10659.00   493.00  -333
-10643.00   495.00  -338
-10121.00   455.00  -346
 -9795.00   456.00  -367
 -8927.00   485.00  -361
 -8765.00   467.00  -351

我想创建一个函数,根据每个坐标 30 的影响圈计算任意给定位置的权重总和。

我想过使用for循环独立计算每个点并对结果求和,但似乎不必要地复杂且效率低下。

我也想过为每个圆圈分配一个颜色强度并覆盖它们,但我不知道如何根据值改变颜色强度这是我目前的尝试(我想看到结果) :

function [] = Influence()

    M = xlsread('MR.xlsx','A4:C310');
    R = xlsread('MR.xlsx','E4:G368'); 
    %these are my values around 300 coordinates

    %M are negative values and R positive, I want to see which are dominant in their regions

    hold on
    scatter(M(:,2),M(:,3),3000,'b','filled')
    scatter(R(:,2),R(:,3),3000,'y','filled')
    axis([350 650 -450 -200])
    hold off
end

%had to use a scalar of 3000 for some reason as it isnt correlated to the graph size

非常感谢ideas/solutions谢谢

This is the same but with ca. 2000 data points

这个怎么样:

r_influence = 30;                                     % radius of influence
r = @(p,A) sqrt((p(1)-A(:,2)).^2 + (p(2)-A(:,3)).^2); % distance
wsum = @(p,A) sum(A(find(r(p,A)<=r_influence),1));    % sum where distance less than roi
% compute sum on a grid
xrange = linspace(350,550,201);
yrange = linspace(-200,-450,201);
[XY,YX] = meshgrid(xrange,yrange);
map_M = arrayfun(@(p1,p2) wsum([p1,p2],M),XY,YX);
map_R = arrayfun(@(p1,p2) wsum([p1,p2],R),XY,YX);

figure(1);
clf;
imagesc(xrange,yrange,map_M + map_R);
colorbar;

给出这样的图片:

这是你要找的吗?