Path: news.mathworks.com!not-for-mail
From: "scott" <grenblau@yahoo.deletethis.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: index array with variable number of dimensions
Date: Mon, 10 Nov 2008 21:54:02 +0000 (UTC)
Organization: Massachusetts Institute of Technology
Lines: 20
Message-ID: <gfaahq$mf4$1@fred.mathworks.com>
References: <gfa3oa$ej8$1@fred.mathworks.com> <YU0Sk.2513$lo6.2424@newsfe01.iad>
Reply-To: "scott" <grenblau@yahoo.deletethis.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1226354042 23012 172.30.248.37 (10 Nov 2008 21:54:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 10 Nov 2008 21:54:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1070812
Xref: news.mathworks.com comp.soft-sys.matlab:500091


Walter Roberson <roberson@hushmail.com> wrote in message <YU0Sk.2513$lo6.2424@newsfe01.iad>...
> scott wrote:
> 
> > Is there any way to have a variable number of dimensions and, say, put the indexes
> > I want for these into a 1D vector and then just index something like:
> >  statisticArray(:,[2 3 4])??
> 
> Use a cell array.
> 
> TheseIndices = {2 3 4};
> statisticArray(:,TheseIndices{:});
> 
> (And if you prefer to work with an array of indices, remember num2cell can
> transform an array of numbers into a cell array of individual numbers.)
> 
> 
> -- 


That seems to have done it - thanks Walter and Loren