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

Jan
Jan 2021년 3월 25일
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.
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()

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2021년 3월 25일

댓글:

2021년 3월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by