For loop with negative array index in MATLAB

  • Thread starter williamrand1
  • Start date
  • Tags Tags
    Loop
3 replies · 2K views · last reply
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!
 
What language is this?
 
jtbell said:
What language is this?

Soory for the delay. The language is matlab.