Explanation

For code generation, the first appearance of a variable must establish its size. The first appearance of a variable cannot be subscripted.


Suggested Action

Create the array by assigning values to the entire array before subscripting it. You can allocate values to the array, for example, by using the zeros function. Other useful functions for initializing arrays are struct and repmat.