Problem with For Loop - Any Help Appreciated

  • Thread starter Thread starter williamrand1
  • Start date Start date
  • Tags Tags
    Loop
AI Thread Summary
The discussion centers around a coding issue with a for loop in MATLAB. The user initially presents a simple code snippet that generates an error due to the use of a negative index in the for loop. After some clarification, the user confirms that the programming language in question is MATLAB and later indicates that they have resolved the issue on their own.
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
What language is this?
 
jtbell said:
What language is this?

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