Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: return indices _ issue with find function
Date: Mon, 11 Oct 2010 01:14:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 20
Message-ID: <i8tocr$q50$1@fred.mathworks.com>
References: <i8t188$oo3$1@fred.mathworks.com> <i8t541$lgl$1@fred.mathworks.com> <i8tkmn$9m4$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1286759644 26784 172.30.248.38 (11 Oct 2010 01:14:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 11 Oct 2010 01:14:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:677297

"ravi " <ravi_071@hotmail.com> wrote in message <i8tkmn$9m4$1@fred.mathworks.com>...
> .......
> It wrongly outputs as:
> 
> R =
>     1     2     4     5
> 
> Instead it should be
> 
> R = [ 1  4;
>         2   5]
> .......
- - - - - - - - - -
  Yes, if you are going to use vectors rather than two-dimensional arrays for F and I, you will have to force those two quantities to be column vectors:

 [r,c] = find(F < 4);
 t = I(sub2ind(size(I),r,c));
 R = [c(:),t(:)];

Roger Stafford