http://www.mathworks.com/matlabcentral/newsreader/view_thread/316923
MATLAB Central Newsreader  Search in 3D matrix
Feed for thread: Search in 3D matrix
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Tue, 14 Feb 2012 20:52:40 +0000
Search in 3D matrix
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316923#866700
pmassicotte
Hi everyone.<br>
<br>
I have a quick and basic question for most of you.<br>
<br>
I have a 3D matrix let's say<br>
<br>
M = nSample*x*y<br>
<br>
I would like to find index of all 2D matrix that contains values > 100<br>
and remove them from M.<br>
<br>
I know its probaly a very basic question, but I cant get around.<br>
<br>
Regards,<br>
Phil

Tue, 14 Feb 2012 21:30:15 +0000
Re: Search in 3D matrix
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316923#866703
pmassicotte
On 14 fév, 15:52, pmassicotte <pmassico...@hotmail.com> wrote:<br>
> Hi everyone.<br>
><br>
> I have a quick and basic question for most of you.<br>
><br>
> I have a 3D matrix let's say<br>
><br>
> M = nSample*x*y<br>
><br>
> I would like to find index of all 2D matrix that contains values > 100<br>
> and remove them from M.<br>
><br>
> I know its probaly a very basic question, but I cant get around.<br>
><br>
> Regards,<br>
> Phil<br>
<br>
Hi again.<br>
<br>
I think I managed to find a solution with<br>
<br>
[r,c,v] = ind2sub(size(M),find(M > 100));<br>
r = unique(r);<br>
<br>
Regards,<br>
Phil

Tue, 14 Feb 2012 22:41:10 +0000
Re: Search in 3D matrix
http://www.mathworks.com/matlabcentral/newsreader/view_thread/316923#866708
Roger Stafford
pmassicotte <pmassicotte@hotmail.com> wrote in message <3a1c57bd7d2b4931ae905f30ceb9f005@f30g2000yqh.googlegroups.com>...<br>
> On 14 fév, 15:52, pmassicotte <pmassico...@hotmail.com> wrote:<br>
> > I have a 3D matrix let's say<br>
> > M = nSample*x*y<br>
> > I would like to find index of all 2D matrix that contains values > 100<br>
> > and remove them from M.<br>
> I think I managed to find a solution with<br>
> [r,c,v] = ind2sub(size(M),find(M > 100));<br>
> r = unique(r);<br>
         <br>
This ought to work. It avoids your having to use 'unique' which would perform a sorting operation.<br>
<br>
M(find(any(any(M>100,2),3)),:,:) = [];<br>
<br>
Roger Stafford