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:
Find coresponding values in two matrices

Subject: Find coresponding values in two matrices

From: Snow White

Date: 21 Jul, 2010 13:06:05

Message: 1 of 7

Hello,


I have two matrices I and R, i want to find values that are equal to a certain value in I and then find the values at the extracted locations in R as well.

I am using the following code:

[r,c]=find(I==cut_off_val);

to extract values from I (3xn) but find does not traverse row wise it traverses column wise apart from that how do i extract the values from R (3xn (which are a byproduct of I so i can not use intersect))

bye

Subject: Find coresponding values in two matrices

From: Andy

Date: 21 Jul, 2010 13:14:05

Message: 2 of 7

"Snow White" <gulesaman@gmail.com> wrote in message <i26rbs$hbf$1@fred.mathworks.com>...
> Hello,
>
>
> I have two matrices I and R, i want to find values that are equal to a certain value in I and then find the values at the extracted locations in R as well.
>
> I am using the following code:
>
> [r,c]=find(I==cut_off_val);
>
> to extract values from I (3xn) but find does not traverse row wise it traverses column wise apart from that how do i extract the values from R (3xn (which are a byproduct of I so i can not use intersect))
>
> bye

I'm having trouble following your question. Could you provide a small sample I, R, and cut_off_val, and show us what the desired output would look like?

Subject: Find coresponding values in two matrices

From: dpb

Date: 21 Jul, 2010 13:23:56

Message: 3 of 7

Snow White wrote:
> Hello,
>
>
> I have two matrices I and R, i want to find values that are equal to a
> certain value in I and then find the values at the extracted locations
> in R as well.
>
> I am using the following code:
>
> [r,c]=find(I==cut_off_val);
>
> to extract values from I (3xn) but find does not traverse row wise it
> traverses column wise apart from that how do i extract the values from R
> (3xn (which are a byproduct of I so i can not use intersect))

v = R(sub2ind(size(I),r,c));

--

Subject: Find coresponding values in two matrices

From: dpb

Date: 21 Jul, 2010 13:29:58

Message: 4 of 7

dpb wrote:
> Snow White wrote:
>> Hello,
>>
>>
>> I have two matrices I and R, i want to find values that are equal to a
>> certain value in I and then find the values at the extracted locations
>> in R as well.
>>
>> I am using the following code:
>>
>> [r,c]=find(I==cut_off_val);
>>
>> to extract values from I (3xn) but find does not traverse row wise it
>> traverses column wise apart from that how do i extract the values from
>> R (3xn (which are a byproduct of I so i can not use intersect))
>
> v = R(sub2ind(size(I),r,c));
...

I'll add the caveat about searching for exact matches on floating point
values just in case...

--

Subject: Find coresponding values in two matrices

From: us

Date: 21 Jul, 2010 13:57:06

Message: 5 of 7

"Snow White" <gulesaman@gmail.com> wrote in message <i26rbs$hbf$1@fred.mathworks.com>...
> Hello,
>
>
> I have two matrices I and R, i want to find values that are equal to a certain value in I and then find the values at the extracted locations in R as well.
>
> I am using the following code:
>
> [r,c]=find(I==cut_off_val);
>
> to extract values from I (3xn) but find does not traverse row wise it traverses column wise apart from that how do i extract the values from R (3xn (which are a byproduct of I so i can not use intersect))
>
> bye

show CSSM a SMALL yet exemplary data set of your input/desired output...

us

Subject: Find coresponding values in two matrices

From: Snow White

Date: 21 Jul, 2010 14:05:08

Message: 6 of 7

"us " <us@neurol.unizh.ch> wrote in message <i26ubi$1m0$1@fred.mathworks.com>...
> "Snow White" <gulesaman@gmail.com> wrote in message <i26rbs$hbf$1@fred.mathworks.com>...
> > Hello,
> >
> >
> > I have two matrices I and R, i want to find values that are equal to a certain value in I and then find the values at the extracted locations in R as well.
> >
> > I am using the following code:
> >
> > [r,c]=find(I==cut_off_val);
> >
> > to extract values from I (3xn) but find does not traverse row wise it traverses column wise apart from that how do i extract the values from R (3xn (which are a byproduct of I so i can not use intersect))
> >
> > bye
>
> show CSSM a SMALL yet exemplary data set of your input/desired output...
>
> us

I=[1 6 3;4 5 6; 6 8 9]; R=[10 20 30;14 15 16;71 81 91];
 [r,c]=find(I==6);
output should be [20 16 71]

Subject: Find coresponding values in two matrices

From: Andy

Date: 21 Jul, 2010 14:19:04

Message: 7 of 7

"Snow White" <gulesaman@gmail.com> wrote in message <i26uqk$28h$1@fred.mathworks.com>...
> "us " <us@neurol.unizh.ch> wrote in message <i26ubi$1m0$1@fred.mathworks.com>...
> > "Snow White" <gulesaman@gmail.com> wrote in message <i26rbs$hbf$1@fred.mathworks.com>...
> > > Hello,
> > >
> > >
> > > I have two matrices I and R, i want to find values that are equal to a certain value in I and then find the values at the extracted locations in R as well.
> > >
> > > I am using the following code:
> > >
> > > [r,c]=find(I==cut_off_val);
> > >
> > > to extract values from I (3xn) but find does not traverse row wise it traverses column wise apart from that how do i extract the values from R (3xn (which are a byproduct of I so i can not use intersect))
> > >
> > > bye
> >
> > show CSSM a SMALL yet exemplary data set of your input/desired output...
> >
> > us
>
> I=[1 6 3;4 5 6; 6 8 9]; R=[10 20 30;14 15 16;71 81 91];
> [r,c]=find(I==6);
> output should be [20 16 71]

I=[1 6 3;4 5 6; 6 8 9]; R=[10 20 30;14 15 16;71 81 91];
val = 6;
output = R(I==val);

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