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:
finding data

Subject: finding data

From: Jonathan

Date: 26 Feb, 2010 00:40:21

Message: 1 of 5

G'day,

I have two matrices of different lengths, A(2,1000) & B(1,268); note these values will change depending on the data file.

What I would like to do is to finds those elements contained in B that match the same values in A(:,2). I am currently struggling with a for loop with no luck. Any advice would be much appreciated.

Thanks
Jon

Subject: finding data

From: ade77

Date: 26 Feb, 2010 00:51:05

Message: 2 of 5

"Jonathan" <jkakiwi@yahoo.co.uk> wrote in message <hm759l$58d$1@fred.mathworks.com>...
> G'day,
>
> I have two matrices of different lengths, A(2,1000) & B(1,268); note these values will change depending on the data file.
>
> What I would like to do is to finds those elements contained in B that match the same values in A(:,2). I am currently struggling with a for loop with no luck. Any advice would be much appreciated.
>
> Thanks
> Jon

doc ismember
doc find
doc intersect

Subject: finding data

From: Andrew Stevens

Date: 26 Feb, 2010 00:55:23

Message: 3 of 5

"Jonathan" <jkakiwi@yahoo.co.uk> wrote in message <hm759l$58d$1@fred.mathworks.com>...
> G'day,
>
> I have two matrices of different lengths, A(2,1000) & B(1,268); note these values will change depending on the data file.
>
> What I would like to do is to finds those elements contained in B that match the same values in A(:,2). I am currently struggling with a for loop with no luck. Any advice would be much appreciated.
>
> Thanks
> Jon

Jon,
Take a look at:
ISMEMBER

-Andrew

Subject: finding data

From: Jonathan

Date: 26 Feb, 2010 01:27:04

Message: 4 of 5

Thanks,

my code....
B = (208,1)
A = (368183,2)
....
[tf,loc] = ismember(B, A);

gives me a new file 'loc' that identifies the position of values in A that match B.

However, how do I create a new file that has the two columns of data in A that matches B?

What I am really after are the corresponding values in A(:,1), based on matching the values in B with the values in A(:,2).

Thanks
Jon



Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <hm765r$1ai$1@fred.mathworks.com>...
> "Jonathan" <jkakiwi@yahoo.co.uk> wrote in message <hm759l$58d$1@fred.mathworks.com>...
> > G'day,
> >
> > I have two matrices of different lengths, A(2,1000) & B(1,268); note these values will change depending on the data file.
> >
> > What I would like to do is to finds those elements contained in B that match the same values in A(:,2). I am currently struggling with a for loop with no luck. Any advice would be much appreciated.
> >
> > Thanks
> > Jon
>
> Jon,
> Take a look at:
> ISMEMBER
>
> -Andrew

Subject: finding data

From: Jonathan

Date: 26 Feb, 2010 01:38:04

Message: 5 of 5

I think I figured it out.

Thanks for the help.

"Jonathan" <jkakiwi@yahoo.co.uk> wrote in message <hm7818$q2h$1@fred.mathworks.com>...
> Thanks,
>
> my code....
> B = (208,1)
> A = (368183,2)
> ....
> [tf,loc] = ismember(B, A);
>
> gives me a new file 'loc' that identifies the position of values in A that match B.
>
> However, how do I create a new file that has the two columns of data in A that matches B?
>
> What I am really after are the corresponding values in A(:,1), based on matching the values in B with the values in A(:,2).
>
> Thanks
> Jon
>
>
>
> Andrew Stevens" <astevens@JUNKusgs.gov> wrote in message <hm765r$1ai$1@fred.mathworks.com>...
> > "Jonathan" <jkakiwi@yahoo.co.uk> wrote in message <hm759l$58d$1@fred.mathworks.com>...
> > > G'day,
> > >
> > > I have two matrices of different lengths, A(2,1000) & B(1,268); note these values will change depending on the data file.
> > >
> > > What I would like to do is to finds those elements contained in B that match the same values in A(:,2). I am currently struggling with a for loop with no luck. Any advice would be much appreciated.
> > >
> > > Thanks
> > > Jon
> >
> > Jon,
> > Take a look at:
> > ISMEMBER
> >
> > -Andrew

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