Distance between distance between [ x_0,y_00] to [x_10,y_100] coordinates in Cell array
Show older comments
I have a cell array having [x,y] coordinates as shown below.
{{[ x_0,y_00]},
{[ x_1,y_10],[ x_1,y_11],[ x_1,y_12],[ x_1,y_13],[ x_1,y_14],[ x_1,y_15]},
{[ x_2,y_20],[ x_2,y_21],[ x_2,y_22],[ x_2,y_23],[ x_2,y_24],[ x_2,y_25]},
{[ x_3,y_30],[ x_3,y_31],[ x_3,y_32],[ x_3,y_33],[ x_3,y_34],[ x_3,y_35]},
{[ x_4,y_40],[ x_4,y_41],[ x_4,y_42],[ x_4,y_43],[ x_4,y_44],[ x_4,y_45]},
{[ x_5,y_50],[ x_5,y_51],[ x_5,y_52],[ x_5,y_53],[ x_5,y_54],[ x_5,y_55]},
{[ x_6,y_60],[ x_6,y_61],[ x_6,y_62],[ x_6,y_63],[ x_6,y_64],[ x_6,y_65]},
{[ x_7,y_70],[ x_7,y_71],[ x_7,y_72],[ x_7,y_73],[ x_7,y_74],[ x_7,y_75]},
{[ x_8,y_80],[ x_8,y_81],[ x_8,y_82],[ x_8,y_83],[ x_8,y_84],[ x_8,y_85]},
{[ x_9,y_90],[ x_9,y_91],[ x_9,y_92],[ x_9,y_93],[ x_9,y_94],[ x_9,y_95]},
{[x_10,y_100]}}
The values of y coordinates are random. How can I find the minimum distance between [ x_0,y_00] to [x_10,y_100]. distance? Can someone please guide me.
2 Comments
Guillaume
on 19 Sep 2018
The question is really badly explained. If I understand correctly, your cell array represent a directly acyclic graph where the points on each layer of your upper level cell array is connected to each point on the next layer, and you want to find the shortest path going from the 1st cell to the last cell using only one point from each intermediate cell array.
Is that correct?
rest12
on 19 Sep 2018
Accepted Answer
More Answers (1)
KSSV
on 19 Sep 2018
A = {{rand(2,1)},{rand(2,1)},{rand(2,1)},{rand(2,1)},{rand(2,1)}} ;
A = cell2mat([A{:}]) ;
A = A';
d = pdist2(A(1,:),A) ;
[val,idx] = max(d) ;
iwant = A(idx,:)
1 Comment
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!