cns_iconv

Converts cell indices between representations of different dimensionality, e.g., between N-D indices and 1-D (linear) indices.

In MATLAB, elements of an N-D array can be accessed using any number of indices from 1 to N. When using D < N indices, the dimensions (D : N) are treated as a single dimension, indexed by the Dth index. This can be quite useful.

This function is a generalization of MATLAB's sub2ind and ind2sub functions. cns_iconv converts indices between any two representations (D1 ≤ N) and (D2 ≤ N).

Syntax

[j1, j2, ...] = cns_iconv(m, z, i1, i2, ...)
m
A model structure.

z
The layer number.

i1, i2, ...
The indices of a cell in layer z. From 1 to N numbers, where N is the dimensionality of the layer. These can also be arrays (for multiple cells), but must all be of the same size.

j1, j2, ...
The indices of the same cell using a (presumably different) dimensionality representation. The output dimensionality is determined by the number of outputs. For multiple cells, each j will be the same size as the i inputs.