0

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)

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • This resource is more about programming than science. If you need some help with the code provide it. – Teivaz Apr 23 '16 at 10:06
  • My question is not really about the science, I just want to know how to extract the row and column indexes of those elements from a Matlab matrix. – S. Lundregan Apr 23 '16 at 10:15
  • have you tried google? http://www.mathworks.com/help/matlab/matlab_prog/find-array-elements-that-meet-a-condition.html – Teivaz Apr 23 '16 at 10:17
  • Actually yes, for several hours now. I could not find the answer I wanted, hence asking here... I didn't find the answer on that link either. – S. Lundregan Apr 23 '16 at 10:21
  • Basically you are asking "How can I find the indexes of elements that are less than a value?" And this is described in the page I provided. If there is a problem with your specific task then provide the code you've tried and we'll try to figure out how to fix it – Teivaz Apr 23 '16 at 10:24
  • That is the first part of my question, yes, but doesn't include the second part. My question is "How can I find the indexes of elements that are less than a value, EXCLUDING rows and columns eg. 2,7,12,15". I agree that the answer to the first part of the question is on the page you linked, but I cannot find out how to exclude certain rows from the query anywhere. – S. Lundregan Apr 23 '16 at 10:29
  • That is a fourth use of *"Cobra"* (the 3 others are described in [the tag wiki](https://stackoverflow.com/tags/cobra/info)). – Peter Mortensen Mar 04 '20 at 02:51

1 Answers1

0

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));
    
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
BillBokeey
  • 3,168
  • 14
  • 28