Real-Time Workshop 5.6 (R2010b) treats multidimensional data as 1-D and it serializes it such that when you access x, x, x in the generated code, the generated code expects to be moving down columns and then moving to the next column. Thus multidimensional arrays are ordered in a column-major format and not a row-major format in the generated code.
To work around this issue, there are two options:
1. One option is to re-order the 2D variable definition in the hand code so that it is ordered correctly in the generated code.
2. The second option is to use the get/set custom storage class with the data. The get/set custom storage classes replace variable reads and writes with user-specified function calls. The user has to implement those function calls, but in this case, that provides a perfect place for the user to do the array access the way that he wants it.
For more information on GET SET Custom Storage Class refer to the following documentation link:
On embedded systems, the overhead of the extra function call might be unacceptable to the user in which case the first option may be used instead.