Problem with For Loop - Any Help Appreciated

  • Thread starter Thread starter williamrand1
  • Start date Start date
  • Tags Tags
    Loop
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
williamrand1
Messages
21
Reaction score
0
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!
 
Physics news on Phys.org
jtbell said:
What language is this?

Soory for the delay. The language is matlab.
 
Ive figured it out lads so thanks anyway...