|
From: | Alexander Barth |
Subject: | Re: Disaggregating input arguments for sub2ind |
Date: | Thu, 20 Feb 2014 22:46:52 +0100 |
> _______________________________________________On Wed, Feb 19, 2014 at 2:38 PM, Nir Krakauer <address@hidden> wrote:
> 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
>
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
>
Nir,
Besides having eval statement with the parametrized string, I
wouldn't know any other way, since it seems sub2ind doesn't accept
zipped arguments... something like the **kargs in python.
I hope Jordi corrects me on this.
_______________________________________________
Help-octave mailing list
address@hidden
https://mailman.cae.wisc.edu/listinfo/help-octave
[Prev in Thread] | Current Thread | [Next in Thread] |