Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!newsfe01.iad.POSTED!7564ea0f!not-for-mail
From: Walter Roberson <roberson@hushmail.com>
Organization: Canada Eat The Cookie Foundation
User-Agent: Thunderbird 2.0.0.17 (Windows/20080914)
MIME-Version: 1.0
Newsgroups: comp.soft-sys.matlab
Subject: Re: index array with variable number of dimensions
References: <gfa3oa$ej8$1@fred.mathworks.com> <MPG.23826460bc5e63ce9898ea@news.mathworks.com>
In-Reply-To: <MPG.23826460bc5e63ce9898ea@news.mathworks.com>
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 25
Message-ID: <yQ2Sk.3011$Gm3.2484@newsfe01.iad>
NNTP-Posting-Host: 24.79.146.116
X-Complaints-To: internet.abuse@sjrb.ca
X-Trace: newsfe01.iad 1226357150 24.79.146.116 (Mon, 10 Nov 2008 22:45:50 UTC)
NNTP-Posting-Date: Mon, 10 Nov 2008 22:45:50 UTC
Date: Mon, 10 Nov 2008 16:46:09 -0600
Xref: news.mathworks.com comp.soft-sys.matlab:500102


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 ?

-- 
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?