Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: find elements to include page indices
Date: Thu, 24 Jul 2008 08:33:04 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 37
Message-ID: <g69eo0$ntt$1@fred.mathworks.com>
References: <g677t2$j92$1@fred.mathworks.com> <g69cqo$gsb$1@fred.mathworks.com> <g69e92$js4$1@fred.mathworks.com>
Reply-To: <HIDDEN>
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 1216888384 24509 172.30.248.37 (24 Jul 2008 08:33:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 24 Jul 2008 08:33:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:481446



"Dave Brackett":
<SNIP simple question...

> ok, and then how can I find the elements of another matrix
> using the indices from this result...

...one of the (simple) solutions

% the data
     m=zeros([2,3,4]);
     m(1,1,1)=nan;
     m(2,2,3)=nan;
     m(2,3,4)=nan;
% the engine
     lix=find(m);
     ix=cell(1,ndims(m));
     [ix{1:end}]=ind2sub(size(m),lix);
     r=cat(2,ix{:});
% the result
     disp(r);
%{
     1 1 1
     2 2 3
     2 3 4
%}

     m(isnan(m))=-1;
     lix=sub2ind(size(m),ix{:});
     r=m(lix);
     disp(r);
%{
     -1
     -1
     -1
%}

us