Path: news.mathworks.com!not-for-mail
From: Loren Shure <loren@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: index array with variable number of dimensions
Date: Tue, 11 Nov 2008 09:00:52 -0500
Organization: The MathWorks
Lines: 32
Message-ID: <MPG.23835a1bf3365ee59898ec@news.mathworks.com>
References: <gfa3oa$ej8$1@fred.mathworks.com> <MPG.23826460bc5e63ce9898ea@news.mathworks.com> <yQ2Sk.3011$Gm3.2484@newsfe01.iad>
NNTP-Posting-Host: shurel.dhcp.mathworks.com
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-15"
Content-Transfer-Encoding: 7bit
X-Trace: fred.mathworks.com 1226412052 8132 172.31.57.200 (11 Nov 2008 14:00:52 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 11 Nov 2008 14:00:52 +0000 (UTC)
User-Agent: MicroPlanet-Gravity/2.70.2067
Xref: news.mathworks.com comp.soft-sys.matlab:500203


In article <yQ2Sk.3011$Gm3.2484@newsfe01.iad>, roberson@hushmail.com 
says...
> Loren Shure wrote:
>  
> > nd = ndims(x);
> > index = repmat({':'},1,nd);
>  
> > x(index{:}) gives you nd indexing.
> 
> Interesting -- you can't use 'end' though, and you have to use numeric cell
> arrays instead of strings of numbers... e.g., 
> 
> index = {':' 9 ':'};
> x(index{:})
> 
> -not-
> 
> index = {':' '9' ':'};
> x(index{:})
> 
> The ':' must be treated as a special case ?
> 
> 


yes, and if you create and use the cell area inside an indexed 
expression, then you can use end, (not 'end').

x(max(10,end),1)
-- 
Loren
http://blogs.mathworks.com/loren