title: Subscript indices must either be real positive integers or logicals, generic solution
body: <p>The following error occurs quite frequently:</p>
  
  <blockquote>
    <p>Subscript indices must either be real positive integers or logicals</p>
  </blockquote>
  
  <p>I have found many questions about this but not one with a really generic answer. Hence I would like to have the general solution for dealing with this problem.</p>