
Re: data extraction from matrix to use in another matrix
Posted:
Oct 21, 2013 6:10 PM


I think that this problem is about indexing, and I don't think that I have done a good job explaining what I need to do. This program is about finite element analysis of a bar element, and I have to input a number of nodes that have x,y coordinates, a number of member that have a connectivity between those nodes ( node a to node b or just columns 2 and 3 in matrix conn). Example, element 1 goes from node 5 to node 2, element 11 goes from node 6 to node 7.
What I need to do is to go to element 1, read the value of (conn  row 2) which is 5, go to the coord matrix, find the value (5) in its row 1 and extract the x value that correspond to that location (5) from (conn  row 2) which in this case is (1).
Those values can be stored in a matrix, lets call it M as you named it. I think that the confusion came because I had the other matrices nodeax and nodeay and you probably thought that they existed as part of the input but I just put it there to show how the matrix with the coordinates look like.
conn=[1,5,2;2,2,3;3,3,4;4,4,7;5,3,7;6,3,6;7,6,2;8,5,2;9,1,5;10,5,6;11,6,7]; disp ('Elem # Node(a) Node(b)') disp(conn) coord=[1,0,0;2,2,0;3,4,0;4,6,0;5,1,1;6,3,1,;7,5,1]; disp ('Node # Xcoord Ycoord') disp(coord) M=zeros(length(conn),4); for i=1:length(conn), M(i,:)=[conn(i,:) conn(find(conn(:,1)==conn(i,1)),:)]; end
I apologize for all the confusion and I appreciate you effort. Thanks. Let me know if you need any additional information.

