Dear all,
I have an n-D grid whose size is given by grid_size, and an array of subscripts with size npoints*ndims, for example:
grid_size = [5 4];
grid_subs = [1 4; 5 1; 3 2];
What's a general way to convert the subscripts to single indices, achieving the same result as, for example,
grid_inds = sub2ind (grid_size, grid_subs(:, 1), grid_subs(:, 2)); #2-D case
grid_inds = sub2ind (grid_size, grid_subs(:, 1), grid_subs(:, 2), grid_subs(:, 3)); #3-D case
if the number of dimensions in the grid may vary between calls?
Nir