- #1
hoffmann
- 70
- 0
hi all, here's an interesting problem I've been working on in MATLAB. any help would be appreciated.
i have four column vectors of length ~11000 (table1):
in1 in2 out1 out2
11 4 101 47
1 8 111 9
38 1 1 39
...
i also have a matrix with dimensions 111x111 (matrix1):
c1 c2 c3 c4 ...
c1 0 0 0 1
c2 0 0 1 1
c3 0 1 0 0
c4 1 1 0 0
...
the first four column vectors in table1 represent reactions (read across columns) in which compounds 1 through 111 can participate in. compound 1 in table1 represents a compound with zero mass, so essentially a nonexistent compound. e.g. 11+4=101+47 is the reaction contained in the first row of table 1.
the first reaction in table1 can be classified as A+B=C+D with six possible interactions between the compounds: A-B, A-C, A-D, B-C, B-D, C-D. the second reaction can be classified as A=C+D with its 3 appropriate interactions. the third reaction can be classified as A=D with its 1 interaction.
i basically would like to add 6 more columns to table1 denoting whether an interaction existing in the reaction exists in matrix1. put a 1 in the column when an interaction exists and a 0 otherwise. i need to do this for all reactions in table1. the values in table1 denote the indices of the compounds which should correspond to the row and column labels in matrix1 (i basically added a 'c' tag in front for readability).
i'm having difficulty coding this problem. i would approach it using something like:
for i=1:length(in1)
if matrix1(A,B)==1 && table1(A,B)~=0 %here's where it gets iffy for me
% I'm unsure on how to create columns and make sure i am cross referencing the %elements of table1 and matrix1 properly.
i would appreciate any help since I've tried to conceptualize this problem and believe i am doing so correctly. any more efficient methodologies would be welcome. thanks!
i have four column vectors of length ~11000 (table1):
in1 in2 out1 out2
11 4 101 47
1 8 111 9
38 1 1 39
...
i also have a matrix with dimensions 111x111 (matrix1):
c1 c2 c3 c4 ...
c1 0 0 0 1
c2 0 0 1 1
c3 0 1 0 0
c4 1 1 0 0
...
the first four column vectors in table1 represent reactions (read across columns) in which compounds 1 through 111 can participate in. compound 1 in table1 represents a compound with zero mass, so essentially a nonexistent compound. e.g. 11+4=101+47 is the reaction contained in the first row of table 1.
the first reaction in table1 can be classified as A+B=C+D with six possible interactions between the compounds: A-B, A-C, A-D, B-C, B-D, C-D. the second reaction can be classified as A=C+D with its 3 appropriate interactions. the third reaction can be classified as A=D with its 1 interaction.
i basically would like to add 6 more columns to table1 denoting whether an interaction existing in the reaction exists in matrix1. put a 1 in the column when an interaction exists and a 0 otherwise. i need to do this for all reactions in table1. the values in table1 denote the indices of the compounds which should correspond to the row and column labels in matrix1 (i basically added a 'c' tag in front for readability).
i'm having difficulty coding this problem. i would approach it using something like:
for i=1:length(in1)
if matrix1(A,B)==1 && table1(A,B)~=0 %here's where it gets iffy for me
% I'm unsure on how to create columns and make sure i am cross referencing the %elements of table1 and matrix1 properly.
i would appreciate any help since I've tried to conceptualize this problem and believe i am doing so correctly. any more efficient methodologies would be welcome. thanks!