简体   繁体   中英

MATLAB: Find row index of elements in a matrix <0.001, excluding certain rows

I am using the Cobra Toolbox in MATLAB to perform a double gene knockout study and output for growth ratios is a 100 by 100 matrix called grRatioDble. I need to find the row and column index for elements of this matrix which are <0.001, excluding the rows which were essential on single gene knockout. I have a one-column matrix of the row indexes that I want to exclude. Is there an easy way to do this?

(NB: I cannot just remove the unwanted rows from the matrix as then row, column index changes for the remaining cells)

This piece of code should do the work:

  1. Get all row/col indexes where grRatioDble<0.001 :

     [row,col] = find(grRatioDble<0.001);
  2. Exclude unwanted rows (say the vector containing unwanted rows is rows2exclude ):

     row = row(~ismember(row, rows2exclude)); col = col(~ismember(row, rows2exclude));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM