From: "Bruno Luong" <b.luong@fogale.findmycountry>
Newsgroups: comp.soft-sys.matlab
Subject: Re: multi-dimensional indexing
Date: Sat, 4 Feb 2012 11:23:32 +0000 (UTC)
Organization: FOGALE nanotech
Lines: 19
Message-ID: <jgj4fk$lv3$>
References: <jgh0rp$po9$> <jgh82t$md7$>
Reply-To: "Bruno Luong" <b.luong@fogale.findmycountry>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1328354612 22499 (4 Feb 2012 11:23:32 GMT)
NNTP-Posting-Date: Sat, 4 Feb 2012 11:23:32 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 390839
Xref: comp.soft-sys.matlab:756723

"Steven_Lord" <> wrote in message

> The approach I would use in this case is the comma-separated list approach, 
> though you may want to look at the implementation of the SUB2IND function 
> and write your own function, based on SUB2IND, that accepts a vector of 
> indices rather than individual vectors for the index in each dimension.

That won't really solve the problem of avoid using comma-list, since SUB2IND again requires comma separated-list as input argument.

One way is doing something like this:

A = rand(3,4,5)
ind = [2 1 3]

s = size(A);
A ( 1+(ind-1)*cumprod([1 s(1:end-1)])' )

 % Bruno