Xentius
Xentius

Reputation: 459

MATLAB - real positive integer index

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

Upvotes: 0

Views: 251

Answers (1)

user85109
user85109

Reputation:

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

Upvotes: 6

Related Questions