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:
array compare to matrix

Subject: array compare to matrix

From: what ever

Date: 9 Jun, 2010 18:54:23

Message: 1 of 4

Hello people!

I have a problem i can't fix!

Imagine that i have a array A=[1,2,3,4,5,6]

and a matrix M=[1 6 8 44 7 4]
                      [53 8 3 7 2 8]
                      [1 2 3 4 5 6]
                      [3 5 7 7 3 7]
                      [1 2 3 4 5 6]

I want a final array that give me the position where A and M are the same, in this case the final array should be:

FinalArray=[3 4]

Thanks!!!

And imagine that the last array of M was [1 2.0004 3 4 5.0003 6.0006]

what i should do so that the result also include this one?

Subject: array compare to matrix

From: Walter Roberson

Date: 9 Jun, 2010 19:19:48

Message: 2 of 4

what ever wrote:

> Imagine that i have a array A=[1,2,3,4,5,6]
>
> and a matrix M=[1 6 8 44 7 4]
> [53 8 3 7 2 8]
> [1 2 3 4 5 6]
> [3 5 7 7 3 7]
> [1 2 3 4 5 6]
>
> I want a final array that give me the position where A and M are the
> same,

See the ismember 'rows' option.

Subject: array compare to matrix

From: Roger Stafford

Date: 9 Jun, 2010 19:55:24

Message: 3 of 4

"what ever" <vasco_taveira@hotmail.com> wrote in message <huoo0v$9ib$1@fred.mathworks.com>...
> Hello people!
>
> I have a problem i can't fix!
>
> Imagine that i have a array A=[1,2,3,4,5,6]
>
> and a matrix M=[1 6 8 44 7 4]
> [53 8 3 7 2 8]
> [1 2 3 4 5 6]
> [3 5 7 7 3 7]
> [1 2 3 4 5 6]
>
> I want a final array that give me the position where A and M are the same, in this case the final array should be:
>
> FinalArray=[3 4]
>
> Thanks!!!
>
> And imagine that the last array of M was [1 2.0004 3 4 5.0003 6.0006]
>
> what i should do so that the result also include this one?

  To allow a "tol" amount of differece between A and the row of M:

 p = find(all(abs(M-repmat(A,size(M,1),1))<tol,2)); % Finalarray

Roger Stafford

Subject: array compare to matrix

From: what ever

Date: 12 Jun, 2010 01:01:06

Message: 4 of 4

thanks a lot Walter and Roger!!

Tags for 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