Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Complex Matrix indexing
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
walter Mulvany

Posts: 14
Registered: 10/19/13
Complex Matrix indexing
Posted: Oct 22, 2013 9:36 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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 - column 2) which is 5, go to the coord matrix, find the value (5) in its column 1 and extract the x value that correspond to that location (5) from (coord - column 2) which in this case is (1).

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

The final matrix should look like this:

Elem From To ax ay bx by
1 4 2 0 0 2 0
2 2 3 2 0 4 0
3 3 4 4 0 6 0
4 4 7 6 0 5 1
5 3 7 4 0 5 1
6 3 6 4 0 3 1
7 6 2 3 1 2 0
8 5 2 1 1 2 0
9 1 5 0 0 1 1
10 5 6 1 1 3 1
11 6 7 3 1 5 1



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.