<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094</link>
    <title>MATLAB Central Newsreader - find elements to include page indices</title>
    <description>Feed for thread: find elements to include page indices</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Wed, 23 Jul 2008 12:24:02 -0400</pubDate>
      <title>find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#444848</link>
      <author>Dave Brackett</author>
      <description>I have a matrix of size [1,16,50] and want to find the&lt;br&gt;
positions of the non-zero and zero elements within.&lt;br&gt;
&lt;br&gt;
I have been using find but this only either gives linear&lt;br&gt;
indices or row and column indices. I want it to include page&lt;br&gt;
indices.&lt;br&gt;
&lt;br&gt;
I'm sure this is quite simple to do but I can't seem to work&lt;br&gt;
it out. Any help would be appreciated. Thanks.</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jul 2008 13:06:02 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#444854</link>
      <author>Ian Clarkson</author>
      <description>&quot;Dave Brackett&quot; &amp;lt;davebrackett@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g677t2$j92$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have a matrix of size [1,16,50] and want to find the&lt;br&gt;
&amp;gt; positions of the non-zero and zero elements within.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have been using find but this only either gives linear&lt;br&gt;
&amp;gt; indices or row and column indices. I want it to include page&lt;br&gt;
&amp;gt; indices.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm sure this is quite simple to do but I can't seem to work&lt;br&gt;
&amp;gt; it out. Any help would be appreciated. Thanks.&lt;br&gt;
&lt;br&gt;
how do you define a page index? as in a printed page? or&lt;br&gt;
does your 3d matrix have some relation to pages? i don't&lt;br&gt;
think anybody can help you until you clarify what it is&lt;br&gt;
you're looking to do.</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jul 2008 13:23:02 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#444861</link>
      <author>Dave Brackett</author>
      <description>&quot;Ian Clarkson&quot; &amp;lt;ovoidkumquat@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g67abq$h8d$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Dave Brackett&quot; &amp;lt;davebrackett@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;g677t2$j92$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; I have a matrix of size [1,16,50] and want to find the&lt;br&gt;
&amp;gt; &amp;gt; positions of the non-zero and zero elements within.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I have been using find but this only either gives linear&lt;br&gt;
&amp;gt; &amp;gt; indices or row and column indices. I want it to include page&lt;br&gt;
&amp;gt; &amp;gt; indices.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I'm sure this is quite simple to do but I can't seem to work&lt;br&gt;
&amp;gt; &amp;gt; it out. Any help would be appreciated. Thanks.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; how do you define a page index? as in a printed page? or&lt;br&gt;
&amp;gt; does your 3d matrix have some relation to pages? i don't&lt;br&gt;
&amp;gt; think anybody can help you until you clarify what it is&lt;br&gt;
&amp;gt; you're looking to do.&lt;br&gt;
&lt;br&gt;
sorry, by page indices I mean with regards to a 3D matrix.&lt;br&gt;
i.e. for a matrix of size [1,16,50] the first dimension is&lt;br&gt;
the rows, the second is the cols, and the third is the&lt;br&gt;
pages. It has nothing to do with physical pages of paper.</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jul 2008 13:38:56 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#444866</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Dave Brackett&quot; &amp;lt;davebrackett@hotmail.com&amp;gt; wrote in message &lt;br&gt;
news:g677t2$j92$1@fred.mathworks.com...&lt;br&gt;
&amp;gt;I have a matrix of size [1,16,50] and want to find the&lt;br&gt;
&amp;gt; positions of the non-zero and zero elements within.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have been using find but this only either gives linear&lt;br&gt;
&amp;gt; indices or row and column indices. I want it to include page&lt;br&gt;
&amp;gt; indices.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I'm sure this is quite simple to do but I can't seem to work&lt;br&gt;
&amp;gt; it out. Any help would be appreciated. Thanks.&lt;br&gt;
&lt;br&gt;
Use FIND to obtain the linear indices then use IND2SUB to convert them into &lt;br&gt;
row, column, and page subscripts.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Wed, 23 Jul 2008 13:42:25 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#444869</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Ian Clarkson&quot; &amp;lt;ovoidkumquat@hotmail.com&amp;gt; wrote in message &lt;br&gt;
news:g67abq$h8d$1@fred.mathworks.com...&lt;br&gt;
&amp;gt; &quot;Dave Brackett&quot; &amp;lt;davebrackett@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;g677t2$j92$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; I have a matrix of size [1,16,50] and want to find the&lt;br&gt;
&amp;gt;&amp;gt; positions of the non-zero and zero elements within.&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; I have been using find but this only either gives linear&lt;br&gt;
&amp;gt;&amp;gt; indices or row and column indices. I want it to include page&lt;br&gt;
&amp;gt;&amp;gt; indices.&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&amp;gt; I'm sure this is quite simple to do but I can't seem to work&lt;br&gt;
&amp;gt;&amp;gt; it out. Any help would be appreciated. Thanks.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; how do you define a page index? as in a printed page? or&lt;br&gt;
&amp;gt; does your 3d matrix have some relation to pages? i don't&lt;br&gt;
&amp;gt; think anybody can help you until you clarify what it is&lt;br&gt;
&amp;gt; you're looking to do.&lt;br&gt;
&lt;br&gt;
When dealing with arrays in MATLAB, the term 'page' generally refers to the &lt;br&gt;
third dimension.  For instance, if x is:&lt;br&gt;
&lt;br&gt;
x = ones(1, 16, 50);&lt;br&gt;
y = x(:, :, 6);&lt;br&gt;
&lt;br&gt;
x has 1 row, 16 columns, and 50 pages, and y contains all the rows and &lt;br&gt;
columns in the 6th page of x.&lt;br&gt;
&lt;br&gt;
And to answer the follow-up question I anticipate:  I don't think there's &lt;br&gt;
any generally used corresponding terms for any higher dimensions.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Wed, 23 Jul 2008 14:38:04 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#444899</link>
      <author>Dave Brackett</author>
      <description>&amp;gt; Use FIND to obtain the linear indices then use IND2SUB to&lt;br&gt;
convert them into &lt;br&gt;
&amp;gt; row, column, and page subscripts.&lt;br&gt;
&lt;br&gt;
Ok, so for a matrix, x of size [1 16 50]:&lt;br&gt;
&lt;br&gt;
linear_non0=find(x) % to find non zero elements (size [788 1])&lt;br&gt;
linear_0=find(x==0) % to find zero elements (size [12 1])&lt;br&gt;
&lt;br&gt;
[I J K]=ind2sub(linear_non0,[1 16 50])&lt;br&gt;
[I0 J0 K0]=ind2sub(linear_0,[1 16 50])&lt;br&gt;
&lt;br&gt;
however, this returns the error:&lt;br&gt;
??? Error using ==&amp;gt; horzcat&lt;br&gt;
CAT arguments dimensions are not consistent.&lt;br&gt;
&lt;br&gt;
Error in ==&amp;gt; ind2sub at 30&lt;br&gt;
&amp;nbsp;&amp;nbsp;siz = [siz(1:nout-1) prod(siz(nout:end))];&lt;br&gt;
&lt;br&gt;
I think this related to the second argument i.e. [1 16 50].&lt;br&gt;
I have looked at the help but can't figure out what to put&lt;br&gt;
for this argument. thanks.</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jul 2008 15:10:03 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#444912</link>
      <author>Ian Clarkson</author>
      <description>&quot;Dave Brackett&quot; &amp;lt;davebrackett@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g67foc$92q$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Use FIND to obtain the linear indices then use IND2SUB to&lt;br&gt;
&amp;gt; convert them into &lt;br&gt;
&amp;gt; &amp;gt; row, column, and page subscripts.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Ok, so for a matrix, x of size [1 16 50]:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; linear_non0=find(x) % to find non zero elements (size [788 1])&lt;br&gt;
&amp;gt; linear_0=find(x==0) % to find zero elements (size [12 1])&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; [I J K]=ind2sub(linear_non0,[1 16 50])&lt;br&gt;
&amp;gt; [I0 J0 K0]=ind2sub(linear_0,[1 16 50])&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; however, this returns the error:&lt;br&gt;
&amp;gt; ??? Error using ==&amp;gt; horzcat&lt;br&gt;
&amp;gt; CAT arguments dimensions are not consistent.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Error in ==&amp;gt; ind2sub at 30&lt;br&gt;
&amp;gt;   siz = [siz(1:nout-1) prod(siz(nout:end))];&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I think this related to the second argument i.e. [1 16 50].&lt;br&gt;
&amp;gt; I have looked at the help but can't figure out what to put&lt;br&gt;
&amp;gt; for this argument. thanks.&lt;br&gt;
&lt;br&gt;
i believe you have your inputs to the ind2sub switched: the&lt;br&gt;
first argument is the size and the second argument are the&lt;br&gt;
values you're interested in.</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jul 2008 16:23:02 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#444925</link>
      <author>Dave Brackett</author>
      <description>&amp;gt; i believe you have your inputs to the ind2sub switched: the&lt;br&gt;
&amp;gt; first argument is the size and the second argument are the&lt;br&gt;
&amp;gt; values you're interested in.&lt;br&gt;
&lt;br&gt;
ah yeah, thanks. I can now get the subscripts and have&lt;br&gt;
assigned them to a variable, a, which is then of the size&lt;br&gt;
[788 3] with rows like:&lt;br&gt;
&lt;br&gt;
[1 2 1;&lt;br&gt;
&amp;nbsp;1 6 1;&lt;br&gt;
&amp;nbsp;1 9 1;&lt;br&gt;
&amp;nbsp;1 10 1;&lt;br&gt;
&amp;nbsp;1 11 1;&lt;br&gt;
&amp;nbsp;1 12 1;&lt;br&gt;
&amp;nbsp;...etc]&lt;br&gt;
&lt;br&gt;
I want to use the indices at each row to extract the&lt;br&gt;
corresponding elements from another matrix, b, which is of&lt;br&gt;
the size [90 16 50].&lt;br&gt;
&lt;br&gt;
I tried to implement this as simply c=b(a) but I get c as of&lt;br&gt;
the size [788 3] whereas it should be of the form [90 16 50].&lt;br&gt;
&lt;br&gt;
If I write c=b(1,2,1) I can get a single element, but if i&lt;br&gt;
write c=b([1 2 1]) i get 3 elements. Why is there a&lt;br&gt;
difference between these 2 methods? I think this might be&lt;br&gt;
the cause of this problem.&lt;br&gt;
&lt;br&gt;
Thanks</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jul 2008 17:15:05 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#444936</link>
      <author>Ian Clarkson</author>
      <description>&quot;Dave Brackett&quot; &amp;lt;davebrackett@hotmail.com&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g67lt6$4c9$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; i believe you have your inputs to the ind2sub switched: the&lt;br&gt;
&amp;gt; &amp;gt; first argument is the size and the second argument are the&lt;br&gt;
&amp;gt; &amp;gt; values you're interested in.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ah yeah, thanks. I can now get the subscripts and have&lt;br&gt;
&amp;gt; assigned them to a variable, a, which is then of the size&lt;br&gt;
&amp;gt; [788 3] with rows like:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; [1 2 1;&lt;br&gt;
&amp;gt;  1 6 1;&lt;br&gt;
&amp;gt;  1 9 1;&lt;br&gt;
&amp;gt;  1 10 1;&lt;br&gt;
&amp;gt;  1 11 1;&lt;br&gt;
&amp;gt;  1 12 1;&lt;br&gt;
&amp;gt;  ...etc]&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I want to use the indices at each row to extract the&lt;br&gt;
&amp;gt; corresponding elements from another matrix, b, which is of&lt;br&gt;
&amp;gt; the size [90 16 50].&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I tried to implement this as simply c=b(a) but I get c as of&lt;br&gt;
&amp;gt; the size [788 3] whereas it should be of the form [90 16 50].&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If I write c=b(1,2,1) I can get a single element, but if i&lt;br&gt;
&amp;gt; write c=b([1 2 1]) i get 3 elements. Why is there a&lt;br&gt;
&amp;gt; difference between these 2 methods? I think this might be&lt;br&gt;
&amp;gt; the cause of this problem.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
when you access it in the second way, you're getting the&lt;br&gt;
matrix b at the linear indices 1, 2, and 1. Your output will&lt;br&gt;
be something like [num1 num2 num1]. Instead, you should&lt;br&gt;
access it via the linear indices (the ones you found BEFORE&lt;br&gt;
passing to ind2sub). if you use those indices and the&lt;br&gt;
c=b([linearindices]) notation, it should work.</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jul 2008 17:17:19 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#444937</link>
      <author>Steven Lord</author>
      <description>&lt;br&gt;
&quot;Dave Brackett&quot; &amp;lt;davebrackett@hotmail.com&amp;gt; wrote in message &lt;br&gt;
news:g67lt6$4c9$1@fred.mathworks.com...&lt;br&gt;
&amp;gt;&amp;gt; i believe you have your inputs to the ind2sub switched: the&lt;br&gt;
&amp;gt;&amp;gt; first argument is the size and the second argument are the&lt;br&gt;
&amp;gt;&amp;gt; values you're interested in.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ah yeah, thanks. I can now get the subscripts and have&lt;br&gt;
&amp;gt; assigned them to a variable, a, which is then of the size&lt;br&gt;
&amp;gt; [788 3] with rows like:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; [1 2 1;&lt;br&gt;
&amp;gt; 1 6 1;&lt;br&gt;
&amp;gt; 1 9 1;&lt;br&gt;
&amp;gt; 1 10 1;&lt;br&gt;
&amp;gt; 1 11 1;&lt;br&gt;
&amp;gt; 1 12 1;&lt;br&gt;
&amp;gt; ...etc]&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I want to use the indices at each row to extract the&lt;br&gt;
&amp;gt; corresponding elements from another matrix, b, which is of&lt;br&gt;
&amp;gt; the size [90 16 50].&lt;br&gt;
&lt;br&gt;
If the two matrices (the one from which you extract the locations and the &lt;br&gt;
one into which you want to index) are the same size, don't convert the &lt;br&gt;
linear indices into subscripts -- just use the linear indices directly.&lt;br&gt;
&lt;br&gt;
If the two matrices are _not_ the same size, then I'd think a bit more about &lt;br&gt;
the problem.  That seems to me to be an apples and oranges type of &lt;br&gt;
situation.&lt;br&gt;
&lt;br&gt;
&amp;gt; I tried to implement this as simply c=b(a) but I get c as of&lt;br&gt;
&amp;gt; the size [788 3] whereas it should be of the form [90 16 50].&lt;br&gt;
&lt;br&gt;
You're performing linear indexing into b.  The result you get out is the &lt;br&gt;
same size and shape as the matrix of indices.&lt;br&gt;
&lt;br&gt;
&amp;gt; If I write c=b(1,2,1) I can get a single element, but if i&lt;br&gt;
&amp;gt; write c=b([1 2 1]) i get 3 elements. Why is there a&lt;br&gt;
&amp;gt; difference between these 2 methods? I think this might be&lt;br&gt;
&amp;gt; the cause of this problem.&lt;br&gt;
&lt;br&gt;
The former is subscripted indexing.  The latter is linear indexing.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Steve Lord&lt;br&gt;
slord@mathworks.com </description>
    </item>
    <item>
      <pubDate>Thu, 24 Jul 2008 07:45:04 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#445077</link>
      <author>Dave Brackett</author>
      <description>&amp;gt; when you access it in the second way, you're getting the&lt;br&gt;
&amp;gt; matrix b at the linear indices 1, 2, and 1. Your output will&lt;br&gt;
&amp;gt; be something like [num1 num2 num1]. Instead, you should&lt;br&gt;
&amp;gt; access it via the linear indices (the ones you found BEFORE&lt;br&gt;
&amp;gt; passing to ind2sub). if you use those indices and the&lt;br&gt;
&amp;gt; c=b([linearindices]) notation, it should work.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Ok, using linear indices c=b(linearindices) I get c to be a&lt;br&gt;
matrix of the size [788 1]. b is [90 16 50] and so how can i&lt;br&gt;
get c back into the form [90 16 50]? I have tried ind2sub on&lt;br&gt;
c as follows:&lt;br&gt;
&lt;br&gt;
d=ind2sub([90 16 50],real(c))&lt;br&gt;
&lt;br&gt;
but the size of d is still [788 1]. any ideas? thanks for&lt;br&gt;
your help so far.</description>
    </item>
    <item>
      <pubDate>Thu, 24 Jul 2008 08:00:24 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#445079</link>
      <author>us</author>
      <description>&quot;Dave Brackett&quot;&lt;br&gt;
&amp;lt;SNIP looking for his/her bookmarks...&lt;br&gt;
&lt;br&gt;
&amp;gt; I have a matrix of size [1,16,50] and want to find the&lt;br&gt;
&amp;gt; positions of the non-zero and zero elements within...&lt;br&gt;
&lt;br&gt;
one of the many solutions&lt;br&gt;
&lt;br&gt;
% the data&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m=zeros([2,3,4]);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m(1,1,1)=nan;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m(2,2,3)=nan;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m(2,3,4)=nan;&lt;br&gt;
% the engine&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lix=find(m);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ix=cell(1,ndims(m));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[ix{1:end}]=ind2sub(size(m),lix);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r=cat(2,ix{:});&lt;br&gt;
% the result&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;disp(r);&lt;br&gt;
%{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1 1 1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2 2 3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2 3 4&lt;br&gt;
%}&lt;br&gt;
&lt;br&gt;
us</description>
    </item>
    <item>
      <pubDate>Thu, 24 Jul 2008 08:25:06 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#445089</link>
      <author>Dave Brackett</author>
      <description>&amp;gt; % the data&lt;br&gt;
&amp;gt;      m=zeros([2,3,4]);&lt;br&gt;
&amp;gt;      m(1,1,1)=nan;&lt;br&gt;
&amp;gt;      m(2,2,3)=nan;&lt;br&gt;
&amp;gt;      m(2,3,4)=nan;&lt;br&gt;
&amp;gt; % the engine&lt;br&gt;
&amp;gt;      lix=find(m);&lt;br&gt;
&amp;gt;      ix=cell(1,ndims(m));&lt;br&gt;
&amp;gt;      [ix{1:end}]=ind2sub(size(m),lix);&lt;br&gt;
&amp;gt;      r=cat(2,ix{:});&lt;br&gt;
&amp;gt; % the result&lt;br&gt;
&amp;gt;      disp(r);&lt;br&gt;
&amp;gt; %{&lt;br&gt;
&amp;gt;      1 1 1&lt;br&gt;
&amp;gt;      2 2 3&lt;br&gt;
&amp;gt;      2 3 4&lt;br&gt;
&amp;gt; %}&lt;br&gt;
&lt;br&gt;
ok, and then how can I find the elements of another matrix&lt;br&gt;
using the indices from this result as questioned in my&lt;br&gt;
previous message in this thread. thanks.</description>
    </item>
    <item>
      <pubDate>Thu, 24 Jul 2008 08:33:04 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#445092</link>
      <author>us</author>
      <description>&quot;Dave Brackett&quot;:&lt;br&gt;
&amp;lt;SNIP simple question...&lt;br&gt;
&lt;br&gt;
&amp;gt; ok, and then how can I find the elements of another matrix&lt;br&gt;
&amp;gt; using the indices from this result...&lt;br&gt;
&lt;br&gt;
...one of the (simple) solutions&lt;br&gt;
&lt;br&gt;
% the data&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m=zeros([2,3,4]);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m(1,1,1)=nan;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m(2,2,3)=nan;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m(2,3,4)=nan;&lt;br&gt;
% the engine&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lix=find(m);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ix=cell(1,ndims(m));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[ix{1:end}]=ind2sub(size(m),lix);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r=cat(2,ix{:});&lt;br&gt;
% the result&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;disp(r);&lt;br&gt;
%{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1 1 1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2 2 3&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2 3 4&lt;br&gt;
%}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;m(isnan(m))=-1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;lix=sub2ind(size(m),ix{:});&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;r=m(lix);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;disp(r);&lt;br&gt;
%{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-1&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-1&lt;br&gt;
%}&lt;br&gt;
&lt;br&gt;
us</description>
    </item>
    <item>
      <pubDate>Thu, 24 Jul 2008 09:07:22 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#445105</link>
      <author>Dave Brackett</author>
      <description>&quot;us &quot; &amp;lt;us@neurol.unizh.ch&amp;gt; wrote in message&lt;br&gt;
&amp;lt;g69eo0$ntt$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Dave Brackett&quot;:&lt;br&gt;
&amp;gt; &amp;lt;SNIP simple question...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; ok, and then how can I find the elements of another matrix&lt;br&gt;
&amp;gt; &amp;gt; using the indices from this result...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ...one of the (simple) solutions&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % the data&lt;br&gt;
&amp;gt;      m=zeros([2,3,4]);&lt;br&gt;
&amp;gt;      m(1,1,1)=nan;&lt;br&gt;
&amp;gt;      m(2,2,3)=nan;&lt;br&gt;
&amp;gt;      m(2,3,4)=nan;&lt;br&gt;
&amp;gt; % the engine&lt;br&gt;
&amp;gt;      lix=find(m);&lt;br&gt;
&amp;gt;      ix=cell(1,ndims(m));&lt;br&gt;
&amp;gt;      [ix{1:end}]=ind2sub(size(m),lix);&lt;br&gt;
&amp;gt;      r=cat(2,ix{:});&lt;br&gt;
&amp;gt; % the result&lt;br&gt;
&amp;gt;      disp(r);&lt;br&gt;
&amp;gt; %{&lt;br&gt;
&amp;gt;      1 1 1&lt;br&gt;
&amp;gt;      2 2 3&lt;br&gt;
&amp;gt;      2 3 4&lt;br&gt;
&amp;gt; %}&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;      m(isnan(m))=-1;&lt;br&gt;
&amp;gt;      lix=sub2ind(size(m),ix{:});&lt;br&gt;
&amp;gt;      r=m(lix);&lt;br&gt;
&amp;gt;      disp(r);&lt;br&gt;
&amp;gt; %{&lt;br&gt;
&amp;gt;      -1&lt;br&gt;
&amp;gt;      -1&lt;br&gt;
&amp;gt;      -1&lt;br&gt;
&amp;gt; %}&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; us&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Ok I think i may have missed out a crucial bit of info to&lt;br&gt;
achieve what I want, so for clarity to summarise, I want to:&lt;br&gt;
1) get the positions of non 0 values from x&lt;br&gt;
2) use these positions to find the corresponding elements of&lt;br&gt;
b but retain their relative positions, with all other&lt;br&gt;
elements replaced by zeros.&lt;br&gt;
&lt;br&gt;
If possible, I would prefer to use the non-cells method from&lt;br&gt;
earlier in this thread. Thanks for all your help guys.</description>
    </item>
    <item>
      <pubDate>Thu, 24 Jul 2008 12:08:16 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#445142</link>
      <author>Loren Shure</author>
      <description>In article &amp;lt;g69goa$bud$1@fred.mathworks.com&amp;gt;, davebrackett@hotmail.com &lt;br&gt;
says...&lt;br&gt;
&amp;gt; &quot;us &quot; &amp;lt;us@neurol.unizh.ch&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;g69eo0$ntt$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &quot;Dave Brackett&quot;:&lt;br&gt;
&amp;gt; &amp;gt; &amp;lt;SNIP simple question...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ok, and then how can I find the elements of another matrix&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; using the indices from this result...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; ...one of the (simple) solutions&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; % the data&lt;br&gt;
&amp;gt; &amp;gt;      m=zeros([2,3,4]);&lt;br&gt;
&amp;gt; &amp;gt;      m(1,1,1)=nan;&lt;br&gt;
&amp;gt; &amp;gt;      m(2,2,3)=nan;&lt;br&gt;
&amp;gt; &amp;gt;      m(2,3,4)=nan;&lt;br&gt;
&amp;gt; &amp;gt; % the engine&lt;br&gt;
&amp;gt; &amp;gt;      lix=find(m);&lt;br&gt;
&amp;gt; &amp;gt;      ix=cell(1,ndims(m));&lt;br&gt;
&amp;gt; &amp;gt;      [ix{1:end}]=ind2sub(size(m),lix);&lt;br&gt;
&amp;gt; &amp;gt;      r=cat(2,ix{:});&lt;br&gt;
&amp;gt; &amp;gt; % the result&lt;br&gt;
&amp;gt; &amp;gt;      disp(r);&lt;br&gt;
&amp;gt; &amp;gt; %{&lt;br&gt;
&amp;gt; &amp;gt;      1 1 1&lt;br&gt;
&amp;gt; &amp;gt;      2 2 3&lt;br&gt;
&amp;gt; &amp;gt;      2 3 4&lt;br&gt;
&amp;gt; &amp;gt; %}&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;      m(isnan(m))=-1;&lt;br&gt;
&amp;gt; &amp;gt;      lix=sub2ind(size(m),ix{:});&lt;br&gt;
&amp;gt; &amp;gt;      r=m(lix);&lt;br&gt;
&amp;gt; &amp;gt;      disp(r);&lt;br&gt;
&amp;gt; &amp;gt; %{&lt;br&gt;
&amp;gt; &amp;gt;      -1&lt;br&gt;
&amp;gt; &amp;gt;      -1&lt;br&gt;
&amp;gt; &amp;gt;      -1&lt;br&gt;
&amp;gt; &amp;gt; %}&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; us&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Ok I think i may have missed out a crucial bit of info to&lt;br&gt;
&amp;gt; achieve what I want, so for clarity to summarise, I want to:&lt;br&gt;
&amp;gt; 1) get the positions of non 0 values from x&lt;br&gt;
&amp;gt; 2) use these positions to find the corresponding elements of&lt;br&gt;
&amp;gt; b but retain their relative positions, with all other&lt;br&gt;
&amp;gt; elements replaced by zeros.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If possible, I would prefer to use the non-cells method from&lt;br&gt;
&amp;gt; earlier in this thread. Thanks for all your help guys.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
I think you're saying that where x is 0 you want b to also be 0. If &lt;br&gt;
that's true, here goes:&lt;br&gt;
&lt;br&gt;
logind = (x==0);&lt;br&gt;
b(logind) = 0;&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Loren&lt;br&gt;
&lt;a href=&quot;http://blogs.mathworks.com/loren/&quot;&gt;http://blogs.mathworks.com/loren/&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Thu, 24 Jul 2008 12:36:27 -0400</pubDate>
      <title>Re: find elements to include page indices</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/173094#445149</link>
      <author>Peter Boettcher</author>
      <description>&quot;Dave Brackett&quot; &amp;lt;davebrackett@hotmail.com&amp;gt; writes:&lt;br&gt;
&lt;br&gt;
&amp;gt; &quot;us &quot; &amp;lt;us@neurol.unizh.ch&amp;gt; wrote in message&lt;br&gt;
&amp;gt; &amp;lt;g69eo0$ntt$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt;&amp;gt; &quot;Dave Brackett&quot;:&lt;br&gt;
&amp;gt;&amp;gt; &amp;lt;SNIP simple question...&lt;br&gt;
&amp;gt;&amp;gt; &lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; ok, and then how can I find the elements of another matrix&lt;br&gt;
&amp;gt;&amp;gt; &amp;gt; using the indices from this result...&lt;br&gt;
&lt;br&gt;
&amp;gt; Ok I think i may have missed out a crucial bit of info to&lt;br&gt;
&amp;gt; achieve what I want, so for clarity to summarise, I want to:&lt;br&gt;
&amp;gt; 1) get the positions of non 0 values from x&lt;br&gt;
&amp;gt; 2) use these positions to find the corresponding elements of&lt;br&gt;
&amp;gt; b but retain their relative positions, with all other&lt;br&gt;
&amp;gt; elements replaced by zeros.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Yes, crucial indeed.  For this to work I assume x and b are the same&lt;br&gt;
size?  And to restate the question: Where the elements of x are equal to&lt;br&gt;
0, set the corresponding elements of b to 0.&lt;br&gt;
&lt;br&gt;
b(~x) = 0;&lt;br&gt;
&lt;br&gt;
Read the section of the documentation called &quot;Logical Indexing&quot;.&lt;br&gt;
&lt;br&gt;
-Peter</description>
    </item>
  </channel>
</rss>

