0

According to my code I always have real positive integer indexes. (i>1 and 2i-1>1 so I should not have any problem) Can you see what is going wrong here?

Thanks, Amadeus

>> vector=tracks(1,2).matrix

vector =

   33.7275   96.5223   27.9644
   31.7655   95.9838   28.9847
   30.6771   95.9896   29.0000

>> length=tracks(1,2).nPoints

length =

     3

>> for i=length:-1:1 
vector(2i-1,:,:)=vector(i,:,:);
end 
Subscript indices must either be real positive integers or logicals.

>> for i=length:-1:1 i end

i =

     3


i =

     2


i =

     1
Xentius
  • 459
  • 1
  • 10
  • 21
  • In this line: `for i=length:-1:1` you've used not one, but TWO in-built Matlab functions as variable names. General programming rule: Don't use in-built functions as variable names. ps, don't change your `i` subscripts to `j`. `j` is also an inbuilt function :-) – Colin T Bowers Nov 22 '12 at 04:12
  • Also see [this question](http://stackoverflow.com/questions/20054047/subscript-indices-must-either-be-real-positive-integers-or-logicals-generic-sol) for [the generic solution to this problem](http://stackoverflow.com/a/20054048/983722). – Dennis Jaheruddin Nov 27 '13 at 15:50

1 Answers1

6

You should recognize the difference between 2*i and 2i.