1

I have this strange error 'Subscript indices must either be real positive integers or logicals' which most of the times pops up. There a few times though that it doesn't. My code is kind of huge and it has to do with calculating the voronoi diagram without using the voronoi function of MATLAB. The error occurs in one of the bellow code parts each time:

if (PossibleVoronoiPoints(m,2)-Slope(k)*PossibleVoronoiPoints(m,1)-c(k)>0)

or

if (PossibleVoronoiPoints(n,2)-Slope(k)*PossibleVoronoiPoints(n,1)-c(k)<0)

Can anyone help me understand what's going on? If you need the whole code i'll post it with comments if necessary.

co2ark5
  • 45
  • 1
  • 3
  • 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:43

1 Answers1

5

This means what it means: one (or more) of the following subscripts: k, m, or n contains an invalid value. To overcome this error, you need to make sure that each subscript is valid, that it is either a positive integer or a logical (boolean) value (true or false).

If you're not properly familiar with matrix indexing in MATLAB, I suggest that you read this article or see this answer.

Community
  • 1
  • 1
Eitan T
  • 32,660
  • 14
  • 72
  • 109