Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: find elements to include page indices
Date: Wed, 23 Jul 2008 14:38:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 22
Message-ID: <g67foc$92q$1@fred.mathworks.com>
References: <g677t2$j92$1@fred.mathworks.com> <g67c9g$lsl$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1216823884 9306 172.30.248.38 (23 Jul 2008 14:38:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 23 Jul 2008 14:38:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1338633
Xref: news.mathworks.com comp.soft-sys.matlab:481253



> Use FIND to obtain the linear indices then use IND2SUB to
convert them into 
> row, column, and page subscripts.

Ok, so for a matrix, x of size [1 16 50]:

linear_non0=find(x) % to find non zero elements (size [788 1])
linear_0=find(x==0) % to find zero elements (size [12 1])

[I J K]=ind2sub(linear_non0,[1 16 50])
[I0 J0 K0]=ind2sub(linear_0,[1 16 50])

however, this returns the error:
??? Error using ==> horzcat
CAT arguments dimensions are not consistent.

Error in ==> ind2sub at 30
  siz = [siz(1:nout-1) prod(siz(nout:end))];

I think this related to the second argument i.e. [1 16 50].
I have looked at the help but can't figure out what to put
for this argument. thanks.