This article explains how to deal with the error "Invalid index" that occurs during Scilab XCOS simulation.
■Examples
This error occurs when an import in the Superblock is not connected, so fixing the disconnection will resolve the error.
Note that disconnecting a port outside of the superblock will result in a different error.
■Other factors 1. Index is out of range
When you try to access an element of an array or matrix, if the index exceeds the actual size, an error occurs.
For example, specifying indexes such as [4,1] or [1,4] for a 3-row, 3-column matrix will result in an error.
2. Index is 0, negative, or decimal
In Scilab, indexes start with integers from 1, so using 0, negative, or decimal will result in an error.
3. Index is used when array or matrix is empty
If you specify an index for an empty array or matrix, an error will occur.
4. Index is used as a list of indexes that does not match the size of the vector or matrix
When specifying multiple indexes, an error will also occur if the specified dimensions do not match.