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

Popular posts from this blog

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

matlab - error with cyclic autocorrelation function -

php - Using grpc in Laravel, "Class 'Grpc\ChannelCredentials' not found." -