title: How to capture the index of an array in Matlab
body: <p>I have a problem with a capturing the index.</p>
  <p>The error is in the following part of code:</p>
  <pre><code>for i=2:1:7
      for j=1:1:64
          for k=1:1:64
              if (n0(j,:)==data(k,:))%capturing the index of n0 using the table of data
                  n0d=k    ;  %n0d stores captured index                   
              end
  %             n0d
          end
          
          for m=1:1:64
              if(n1(j,:)==data(m,:))%capturing the index of n1 using the table of data
                  n1d=m; %n1d stores capured index
              end
              n1d
          end
          if (~(predecessor(n0d,(i-1))==flag) | ~(predecessor(n1d,(i-1))==flag))
              if(predecessor(n0d,(i-1))~=flag)
              predecessor(j,i)=n0d-1;
              else
                  predecessor(j,i)=n1d-1;
              end
          end
      end
      
  end
  
  
  </code></pre>
  <p>Matlab error:</p>
  <pre><code>Undefined function or variable 'n0d'.
  
  Error in vc_test (line 89)
          if (~(predecessor(n0d,(i-1))==flag) | ~(predecessor(n1d,(i-1))==flag))
  </code></pre>
  <p>I didnt see any mistake in the code. could someone explain why  <code>n0d=k </code> doesnt work?</p>
  <p>EDIT 1: <a href="https://github.com/radhikamathuria25/Soft-Viterbi-Decoder-for-IRNSS/blob/d40afbec002afa6261832e3bff002937a7f3d8f3/Viterbi_decoder_length7.m" rel="nofollow noreferrer">original code</a></p>