inverse distance weighting on matrix
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
jenifer Ask
am 25 Dez. 2019
Bearbeitet: Image Analyst
am 25 Dez. 2019
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 Kommentare
Akzeptierte Antwort
Image Analyst
am 25 Dez. 2019
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 Kommentare
Image Analyst
am 25 Dez. 2019
Bearbeitet: Image Analyst
am 25 Dez. 2019
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?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Labyrinth problems finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!