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 15:10:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 28
Message-ID: <g67hkb$5bl$1@fred.mathworks.com>
References: <g677t2$j92$1@fred.mathworks.com> <g67c9g$lsl$1@fred.mathworks.com> <g67foc$92q$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 1216825803 5493 172.30.248.38 (23 Jul 2008 15:10:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 23 Jul 2008 15:10:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1215962
Xref: news.mathworks.com comp.soft-sys.matlab:481266



"Dave Brackett" <davebrackett@hotmail.com> wrote in message
<g67foc$92q$1@fred.mathworks.com>...
> > 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.

i believe you have your inputs to the ind2sub switched: the
first argument is the size and the second argument are the
values you're interested in.