Matlab Function to produce data from points

Hi
The question i have is say i have a starting position (x and y) (2D)
following that i have 2 colums of randomly generated points to act as x and y (rand(20,1),rand(20,1) for other coordinates
function inputs(x,y,c1,c2) if that makes sense (where c1= rand(20,1 and c2= rand(20,1)
with this infomation im looking to calcualte some data resulting in from the starting position the closest point from the c1 and c2 and from that positon the next one and next one until i find a 'path' that would display for example (1,5,2,6,9,17,13...) to find the shortest distance between all points
is there any possibility to do this?
any advice appreciated

2 Kommentare

Jan
Jan am 25 Mär. 2021
The concatenation of the shortest paths is not necessarily the shortest path over all points, is it?
But of course it is possible to do, what you are asking for. Use pdist() and sort the values.
Samuel Shlong
Samuel Shlong am 25 Mär. 2021
yeah thats okay im just looking to start find the cloest and then find the closest too that one and so on until they are all 'visited'
coming in to using pdist() with my c1 and c2 i require them to be 2 sperate inputs in the function but what would be the way to say for example for 3 rand points
0.323 0.731
0.532 0.421
0.853 0.312
'combine' them to become
1= (0.323,0.731)
2= (0.532,0.421)
3= (0.853,0.312)
and given them an 'id' number if you could possible help with that?
However thanl you for your response also i will look into using the pdist()

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Produkte

Version

R2019b

Gefragt:

am 25 Mär. 2021

Kommentiert:

am 25 Mär. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by