dpb
Posts:
9,849
Registered:
6/7/07


Re: data extraction from matrix to use in another matrix
Posted:
Oct 19, 2013 2:37 PM


On 10/19/2013 1:30 PM, walter Mulvany wrote: > dpb <none@non.net> wrote in message <l3uf4n$nm4$1@speranza.aioe.org>... >> On 10/19/2013 11:03 AM, walter Mulvany wrote: >> > I'm writing a code for finite element analysis and I don't know how to >> > read a value from a matrix (A) and use it as a pointer to direct me to >> > values in another matrix. >> > Here is a sample of the problem. >> ... >> >> > connectivity=[1,1,2;2,1,3;3,2,3] >> ... >> > coordinates=[1,0,0;2,2,0;3,1,2] >> ... >> > I need to read element's 1 node(a) which in this case is 1, and use >> that >> > 1 to direct me to the node 1, extract the x and y coordinate from node >> > 1, and create a matrix. >> ... >> >> Well, it's not clear which you're after, but it's simple enough to >> find a location in an array by value and get the associated >> information from some other for that. >> >> If ask for points in connectivity array that include node 1, that's >> given by >> >> >> conn=[1,1,2;2,1,3;3,2,3]; >> >> coord=[1,0,0;2,2,0;3,1,2]; >> >> idx=any(conn==1,2) % row indices of any connections w/ a '1' >> idx = >> 1 >> 1 >> 0 >> >> coord(idx,:) % get those rows' coordinates... >> ans = >> 1 0 0 >> 2 2 0 >> >> coord(any(conn==1,2),:) % do it w/o the intermediate variable >> ans = >> 1 0 0 >> 2 2 0 >> >> >> >> Look in subject index for "logical addressing" ... >> >>  > Thank you for your input. > This program is supposed to work on a matrix of approximate 100 elements > and what I'm looking for is that every time nodeax(i) iterate, it looks > at the element (i), extract the value of the node (a), then with that > value(ex: 3) it goes to the node 3 in the coordinates matrix and extract > the (x) value of that node and creates nodeax matrix of size[2,nelem]. > Again, thank you for your help, and sorry, but I don't have any > experience programming and this is my first program.
Well, that's the same thing as just demonstrated 
coord(coord(nodeax(i)==i),1)
I'm not certain what you mean by "creates nodeax matrix of size(2,nelem)", sorry...


