Euclidean distance of adjacent pairs of matrix
Show older comments
So i have an example matrix
A = [10 20 30 45
32 94 21 15
67 33 22 54
13 27 89 73]
and i want to calculate the Euclidean distance between adjacent pairs of matrix A. In other words, each row in the matrix is a feature vector, hence the calculation is row-wise.
Pardon my english but I'm having issue understanding "adjacent pairs". Does it mean row1 with row2, row2 with row3 and row3 with row4 OR row1 with row2, row1 with row3 and row1 with row4 OR row1,row2,row3 and row4 all together?
4 Comments
Image Analyst
on 16 Aug 2019
To know whether you'd want to compare row 1 with row 3, which is NOT adjacent, we'd need to know the context in which you generated these rows representing some measurements. Perhaps you want the distance between all rows but you (or someone) just said adjacent but really meant all possible permutations. What's the larger picture of how you got these, what they represent, and what addition information you want to extract/compute from those feature vectors?
Stewart Tan
on 16 Aug 2019
Guillaume
on 16 Aug 2019
As I said in my answer, in order to have an adjacency relationship, you need a total ordering definition on your set (the feature vectors set). Now this is not my domain, but my understanding is that feature vectors can represent any property you choose. So, feature vector A(1) could encode the dominant colours of the image, feature vector A(2) could encode the orientation of lines in the image, and feature vector A(3) could encode whether or not there's a circle in the upper right corner of the image. How you create a total ordering on that, and hence define adjacency, I don't know.
I think you need to dig more into that paper to understand what they're doing.
Bruno Luong
on 16 Aug 2019
Edited: Bruno Luong
on 16 Aug 2019
In graph theory "adjadcent" usually mean topology connected, you don't need necessary to have order defined on the set.
Accepted Answer
More Answers (1)
Guillaume
on 16 Aug 2019
I'm a bit confused by your question. You define something you want to do then ask us to explain your own definition. Isn't the definition whatever you want it to be according to what you want to do?
I guess it all depends on what you call adjacent for feature vectors. Does it even mean anything to spay that two features vectors are adjacent? For that you need to define a total ordering on your feature vector set? Is an ordering meaningful for feature vectors?
Traditionally, you would calculate the euclidean distance between all pairs of the set, something you can do with pdist, or yourself easily:
dist = sqrt(sum(permute(A, [1, 3, 2]).^2 - permute(A, [3, 1, 2]) .^ 2, 3)
dist(i, j) is the euclidean distance between vector A(i) and A(j).
1 Comment
Stewart Tan
on 16 Aug 2019
Categories
Find more on Direction of Arrival Estimation in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!