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

James Tursa
James Tursa 2015년 7월 2일
편집: James Tursa 2015년 7월 2일
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 2015년 7월 2일
No, there are no restrictions on the path.

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

 채택된 답변

James Tursa
James Tursa 2015년 7월 2일
편집: James Tursa 2015년 7월 2일

0 개 추천

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

Zena Assaad
Zena Assaad 2015년 7월 2일
This works well for x and y but it gives zero for all the z values even though the z for point 1 and point 30 are non-zero.
James Tursa
James Tursa 2015년 7월 2일
편집: James Tursa 2015년 7월 2일
It works for me. Probably a typo at your end either for the code above or for the points used. Can you post your Point1 and Point30?
Zena Assaad
Zena Assaad 2015년 7월 2일
편집: Zena Assaad 2015년 7월 2일
point 1: (-2600529.46, 379356.01, 0.004)
Point 30: (6025274.59, 2064061.77, 0.132)
Do you think it's spitting out zero because the z values are so close to zero?
Values are not integers, so get rid of the round function as stated above. E.g.,
Pmatrix = [linspace(Point1(1),Point30(1),30);
linspace(Point1(2),Point30(2),30);
linspace(Point1(3),Point30(3),30)];
Zena Assaad
Zena Assaad 2015년 7월 2일
I did get rid of the round from the beginning the values are still coming up as zero.
James Tursa
James Tursa 2015년 7월 2일
편집: James Tursa 2015년 7월 2일
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 2015년 7월 6일
That worked perfectly. Thank you very much for all your help.

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

질문:

2015년 7월 2일

댓글:

2015년 7월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by