Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Search in 3D matrix

Subject: Search in 3D matrix

From: pmassicotte

Date: 14 Feb, 2012 20:52:40

Message: 1 of 3

Hi everyone.

I have a quick and basic question for most of you.

I have a 3D matrix let's say

M = nSample*x*y

I would like to find index of all 2D matrix that contains values > 100
and remove them from M.

I know its probaly a very basic question, but I cant get around.

Regards,
Phil

Subject: Search in 3D matrix

From: pmassicotte

Date: 14 Feb, 2012 21:30:15

Message: 2 of 3

On 14 fév, 15:52, pmassicotte <pmassico...@hotmail.com> wrote:
> Hi everyone.
>
> I have a quick and basic question for most of you.
>
> I have a 3D matrix let's say
>
> M = nSample*x*y
>
> I would like to find index of all 2D matrix that contains values > 100
> and remove them from M.
>
> I know its probaly a very basic question, but I cant get around.
>
> Regards,
> Phil

Hi again.

I think I managed to find a solution with

[r,c,v] = ind2sub(size(M),find(M > 100));
r = unique(r);

Regards,
Phil

Subject: Search in 3D matrix

From: Roger Stafford

Date: 14 Feb, 2012 22:41:10

Message: 3 of 3

pmassicotte <pmassicotte@hotmail.com> wrote in message <3a1c57bd-7d2b-4931-ae90-5f30ceb9f005@f30g2000yqh.googlegroups.com>...
> On 14 fév, 15:52, pmassicotte <pmassico...@hotmail.com> wrote:
> > I have a 3D matrix let's say
> > M = nSample*x*y
> > I would like to find index of all 2D matrix that contains values > 100
> > and remove them from M.
> I think I managed to find a solution with
> [r,c,v] = ind2sub(size(M),find(M > 100));
> r = unique(r);
- - - - - - - - - -
  This ought to work. It avoids your having to use 'unique' which would perform a sorting operation.

 M(find(any(any(M>100,2),3)),:,:) = [];

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us