inverse distance weighting on matrix
6 次查看(过去 30 天)
显示 更早的评论
hi
I have Below matrix that distanse from 17 point in image
How i can calculate inverse distance weighting on this matrix?
how weighting on distance that have minim distanse for each row?
0 个评论
采纳的回答
Image Analyst
2019-12-25
This 17-by-17 matrix looks like it was made by pdist2(). And you say it is the distance of every point to every other point. If you want 1 over the distance, just do
inverseDistances = 1 ./ Dist;
To get the min value of inverseDistances, do
minsPerRow = min(inverseDistances, [], 2);
To get the min distance of the original Dist, do
dist2 = Dist; % Initialize
dist2(dist2 == 0) = inf; % Trick to get it to ignore zero distances (point to itself)
minsPerRow = min(dist2, [], 2);
3 个评论
Image Analyst
2019-12-25
编辑:Image Analyst
2019-12-25
You can call sort on each row.
s = load('Dis_all.mat')
m = 1 ./ s.Dist
[rows, columns] = size(m)
[sortedDistances, sortedIndexes] = sort(m, 2)
sortedIndexes are the indexes in the original, unsorted array. The first 3 columns of that are the indexes of the three other points that are closest to that point. So
sortedIndexes =
17 16 7 15 14 11 13 12 8 10 5 9 6 4 3 2 1
17 16 7 15 14 11 13 12 8 10 5 9 6 4 3 1 2
17 16 7 15 14 11 8 13 12 10 1 2 5 9 6 4 3
17 16 7 15 14 11 8 13 12 10 1 2 5 9 6 3 4
17 16 7 15 14 1 11 13 2 12 9 8 6 10 4 3 5
17 16 7 8 11 15 14 13 12 10 1 5 2 3 4 9 6
17 16 1 9 2 6 4 3 15 14 5 12 13 10 11 8 7
17 16 1 2 9 6 15 14 7 4 3 13 12 5 11 10 8
17 16 7 8 11 15 14 13 12 10 1 5 2 3 4 6 9
17 16 7 1 2 9 6 3 4 15 14 8 5 11 13 12 10
17 16 1 2 7 9 6 3 4 5 8 15 14 10 12 13 11
17 16 7 1 2 6 9 3 4 8 5 15 14 10 11 13 12
17 16 7 1 2 6 9 3 4 5 8 15 14 10 11 12 13
17 7 1 16 2 6 3 4 9 8 5 10 11 12 13 15 14
17 7 1 16 2 6 3 4 9 8 5 10 11 12 13 14 15
1 2 7 3 4 6 5 9 8 10 11 12 13 14 15 17 16
1 2 3 6 4 9 7 5 8 10 11 12 13 14 15 16 17
You can see that for point 1 (represented by row 1), point 17 is closest, followed by point 16, followed by point 7, with point 2 being farthest away (actually closest in actual distance but farthest in inverse distance).
As another example, for point 16 (represented by row 16) point 1 is closest, followed by point 2, followed by point 7, and point 17 is farthest away.
Why do you want inverse weighting rather than just on the actual distances directly?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Labyrinth problems 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!