Effacer les filtres
Effacer les filtres

inverse distance weighting on matrix

6 vues (au cours des 30 derniers jours)
jenifer Ask
jenifer Ask le 25 Déc 2019
Modifié(e) : Image Analyst le 25 Déc 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?

Réponse acceptée

Image Analyst
Image Analyst le 25 Déc 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 commentaires
Image Analyst
Image Analyst le 25 Déc 2019
Modifié(e) : Image Analyst le 25 Déc 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?
jenifer Ask
jenifer Ask le 25 Déc 2019
Yes, thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by