title: Accessing element index in a matrix
body: <p>I want to save the index of an element in a matrix as following</p>
  <pre class="lang-py prettyprint-override"><code>cx = []
  for j in range(len(self.correctors_indexes)):
      self.lattice[self.correctors_indexes[j]].KickAngle = [self.dkick, 0.00]
  
      lindata0, tune, chrom, lindata = self.lattice.linopt(get_chrom=True, refpts=self.BPM_indexes)    
      closed_orbitx = lindata['closed_orbit'][:, 0]
      cx.append(closed_orbitx)
  
      [row, col] = cx.index(str(closed_orbitx))
      file = open(&quot;orm_x_CXY_&quot;+ [row, col] +&quot;.txt&quot;, &quot;w&quot;)
      str1 = repr(self.lattice[self.correctors_indexes[j]].KickAngle)
      file.write(str1)
      file.close()
  
      Cx = np.squeeze(cx) / self.dkick
      return Cx
  </code></pre>
  <p>But i received the error</p>
  <pre><code>cannot unpack non-iterable int object
  </code></pre>
  <p>Instead i tried to add the function &quot;find&quot;:</p>
  <pre class="lang-py prettyprint-override"><code>def find(element, matrix):
      for i in range(len(matrix)):
          for j in range(len(matrix[i])):
              if matrix[i][j] == element:
                  return (i, j)
  </code></pre>
  <p>And i used it as following:</p>
  <pre class="lang-py prettyprint-override"><code>[row, col] = find(closed_orbitx , cx)
  file = open(&quot;orm_x_CXY_&quot;+ [row, col] +&quot;.txt&quot;, &quot;w&quot;)
  </code></pre>
  <p>But i got the error</p>
  <pre><code>The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
  </code></pre>
  <p>How can i extract the element index in a matrix and use in in the files names?</p>