Finding the path between two points

6 vues (au cours des 30 derniers jours)
Zena Assaad
Zena Assaad le 2 Juil 2015
Commenté : Zena Assaad le 6 Juil 2015
Hi all,
I have two x y z coordinates and I need the path between these two points. It does not necessarily need to be the shortest distance path. I am working with a (3x30) position matrix. The first row represents x, the second row is y and the third row is z.
Point 1: (x1,y1,z1)
Point 30: (x30,y30,z30)
Position matrix: [x1 .......... x30
y1 .......... y30
z1 .......... z30]
Point 1 and point 30 are given. I need something simple that will give me the remaining 28 points within the matrix.
Thanks in advance!
  2 commentaires
James Tursa
James Tursa le 2 Juil 2015
Modifié(e) : James Tursa le 2 Juil 2015
Any restrictions on the path? E.g., is a diagonal jump (two indexes changing at the same time) OK? Can indexes only change a max of 1 for each point?
Zena Assaad
Zena Assaad le 2 Juil 2015
No, there are no restrictions on the path.

Connectez-vous pour commenter.

Réponse acceptée

James Tursa
James Tursa le 2 Juil 2015
Modifié(e) : James Tursa le 2 Juil 2015
E.g., a somewhat "linear" path allowing "diagonal" jumps (more than one index can change at a time):
Point1 = whatever;
Point30 = whatever;
Pmatrix = [round(linspace(Point1(1),Point30(1),30));
round(linspace(Point1(2),Point30(2),30));
round(linspace(Point1(3),Point30(3),30))];
If the points do not need to be integers, then skip the rounding.
  7 commentaires
James Tursa
James Tursa le 2 Juil 2015
Modifié(e) : James Tursa le 2 Juil 2015
They are not zero ... they are just displaying as zero because of the display format you are using (probably short) and the wide range of values in the result. Try this:
format long g
Then display the result again.
Or just look at the last row by itself:
Pmatrix(3,:)
Zena Assaad
Zena Assaad le 6 Juil 2015
That worked perfectly. Thank you very much for all your help.

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 2 Juil 2015

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by