help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing Arbitrary Dimensions


From: dbateman
Subject: Re: Accessing Arbitrary Dimensions
Date: Sat, 1 Mar 2008 12:31:10 -0800 (PST)

I've dealt with pretty much the same issue in the past. The sub2ind method is
slow and not that flexible. I prefer two different solutions 

1) Create a cell array of the correct dimensionality like

idx = cell(ndim, 1)
for i = 1, ndim
  idx {i} = ":";
endfor
idx{dim} = ??;

where ?? is replaced with whatever you want to replace it with to act of the
dimension required. Then you can convert to a cs-list to use it as an index
like x(idx{:}).

2) use permute/ipermute to more the desired dimension to be the first
dimension and then treat the indexing as 2-D (even if the matrix is ND) and
then permute back

D.
-- 
View this message in context: 
http://www.nabble.com/Accessing-Arbitrary-Dimensions-tp15662826p15780584.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]