How to create a weighted adjacency matrix in Matlab

1 view (last 30 days)
I have a dataset in the following format:
UID Lat Long LocID
u1 lt1 lg1 l1
u1 lt2 lg2 l2
u1 lt3 lg3 l3
u2 lt2 lg2 l2
u2 lt4 lg4 l4
u3 lt1 lg1 l1
u3 lt4 lg4 l4
From here I need to generate a LocID-LocID un-directed graph. For this I need a weighted matrix in the following format.
0 d(l1,l2) 0 0
d(l2,1) 0 d(l2,l3) d(l2,l4)
0 d(l3,l2) 0 0
d(l4,l1) d(l4,l2) 0 0
here weight of each edge between two LocID is computed from the given Latitude and Longitude information. Like, d(l1,l2) = distance between LocID-1 and LocID-1 = distance between (lt1,lg1) and (lt2,lg2)
I need to perform this task in matlab.

Answers (0)

Community Treasure Hunt

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

Start Hunting!