title: Why is MATLAB giving me an error that states that "index in position 2 is invalid"?
body: <p>This code seems like it should be simple, but for some reason I keep getting this error: "Index in position 2 is invalid. Array indices must be positive integers or
  logical values."</p>
  
  <p>It refers to these lines: </p>
  
  <pre><code>Vr = (V*R)/(sqrt((R^2)+(w*L-(1/(w*C))^2)));
  VR(1,i) = Vr;
  </code></pre>
  
  <p>I've tried checking if I entered the equation wrong or if I have to save certain values as integers but nothing seems to work. Any advice would be greatly appreciated.</p>
  
  <p>Here's the full code if you need:</p>
  
  <pre><code>disp('Please enter Vo in volts, R in kiloOhms, L in miliHenries, and C in picoFarads');
  input = input('Enter values as single matrix.  ');
  
  V = input(1,1);
  R = input(1,2);
  L = input(1,3);
  C = input(1,4);
  
  VR = zeros(1,1000);      
  
  for i = 0:1000
      w=i*10*10^-9;
      Vr = (V*R)/(sqrt((R^2)+(w*L-(1/(w*C))^2)));
      VR(1,i) = Vr;
  end
  </code></pre>
  
  <p>Thanks!</p>