Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

For loop problem

  1. Jul 27, 2011 #1
    Hi all,

    Im having a problem with the for loop. Any help would be great!!

    The code is simple,

    x = -3:0.5:3;

    For i = x

    q(i) = i^2;

    end

    q

    The error seems to be the negative index in the statement of the for loop.

    Hope this is clear. Thanks!!
     
  2. jcsd
  3. Jul 27, 2011 #2

    jtbell

    User Avatar

    Staff: Mentor

    What language is this?
     
  4. Jul 27, 2011 #3
    Soory for the delay. The language is matlab.
     
  5. Jul 27, 2011 #4
    Ive figured it out lads so thanks anyway....
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook