matlab - How can using the existing fields, the value of another field achieved? -
i have table follows:
cl c2 c3 ..... r1 x 4 r2 y b 5 r3 z c 2 . . .
r(1,2,3) label of rows , c(1,2,3) label of columns. have field of c1,c2 , want c3. example have y , b, want achieve '5'; read 'find , sub2ind' functions not know how can use them case.
you can use simple logical indexing accomplish this. want third column when value of first column 'y'
, value of second column 'b'
t = table({'x'; 'y'; 'z'}, {'a'; 'b'; 'c'}, [4; 5; 2], 'variablenames', {'c1', 'c2', 'c3'}); value = t.c3(ismember(t.c1, 'y') & ismember(t.c2, 'b')) % 5
Comments
Post a Comment