Re-Asking a Question: Creating a Connection Matrix from an indexed point set

5 views (last 30 days)
Hello, all, I am re-asking a question because of a lot of ambiguity with my original post.
Simply put, I want to create a matrix depicting the connection of indexed points.
What I had to begin with is a 7xN matrix, where each row had the radius for segment, and the x y and z coordinates of the two points that made up the line.
Because the first point was from the first three column entries, and the second point form the second three column entries, I put them into two 3xN matrices: my "from point" matrix which had the first three coordinates for each parent segment, and the "to point" matrix which had the last three coordinates for each daughter point.
Since every daughter point was unique, I added all of the elements of the "to point" matrix, plus the beginning point, into my revised point matrix, which I added a column segment incrementor (so I know exactly what point 1 coordinates are, etc). I then indexed my set, so I have something like:
1 0 0 10
2 0 0 0
3 3 4 -4
4 2 6 -10
etc.
Now, with my indexed point matrix, I want to go back to my "from point" parent matrix, and compare the items row by row with my indexed matrix 2-4th numbers, and spit out the indexes of the points as a connection matrix.
so, if my "from point" matrix and indexed set looked like:
FROM POINT MX INDEXED POINT MX
I want to create a connection (or face) matrix, with the elements:
5,2
4,3
2,4
3,5
This is just an example. The second column will always be an incremented value of 2 to N point, because the "to point" will always be denoted by the indexed value of the index matrix.
Is this clear so far? I apologize for the ambiguity of my original statement.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 29 May 2012
a - your matrix
a =[0 0 10
0 0 0
3 4 -4
2 6 10];
fp = [ 0 0 10
2 6 10
0 0 0
3 4 -4];
tp = [0 0 0
3 4 -4
2 6 10
0 0 10];
[l1,l1] = ismember(fp,a,'rows');
[l2,l2] = ismember(tp,a,'rows');
out = [l1, l2];

More Answers (1)

Stephen
Stephen on 29 May 2012
after looking at it for a while I think I understand. let me use N=3 to try and restate what you've asked...
from points,
fp=
[3 2 1;
4 5 6;
7 9 8];
to points,
tp=
[4 5 6;
7 9 8;
3 2 1];
you would need the matrix
m = [1 2;
2 3;
3 1];
which only refers to the indices of the points in the first list of 'from points'
maybe try a for loop
N=3;
m=[];
for t=1:N
dex=1;
while ~isequal(fp(t,:),tp(dex,:))
dex=dex+1;
end
m=[m;t dex];
end
kind of brute force but something like that should work, good luck
  1 Comment
Brian
Brian on 29 May 2012
Thank you! I will definitely try this out
I've been stuck on this for a day or two, and I only have limited experience in MATLAB.

Sign in to comment.

Categories

Find more on Resizing and Reshaping Matrices 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!