Got Questions? Get Answers.
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:
extract rows given Index matrix

Subject: extract rows given Index matrix

From: Kurt

Date: 9 Dec, 2010 21:31:05

Message: 1 of 3

Hello guys,

I am given a matrix A , which is also accompanied by an Index Matrix:

A =
         10
         20
         30
         40
         50

Index =
                 1 2
                 1 3
                 2 1
                 3 4
                 5 7

The rows of 'A' correspond to the rows of 'Index'.

Now, I am given another Index matrix which I call 'Index_hat'.

Index_hat =
                        1 3
                        3 4
                        5 7

Given this 'Index_hat' matrix I want to extract its corresponding rows in 'A', i.e.

new_A =
                   20
                   40
                   50

Any help much appreciated.

all the best,
kurtis


                 

Subject: extract rows given Index matrix

From: Sean de

Date: 9 Dec, 2010 21:41:24

Message: 2 of 3

"Kurt " <rerty258@gmail.com> wrote in message <idrhqp$i8l$1@fred.mathworks.com>...
> Hello guys,
>
> I am given a matrix A , which is also accompanied by an Index Matrix:
>
> A =
> 10
> 20
> 30
> 40
> 50
>
> Index =
> 1 2
> 1 3
> 2 1
> 3 4
> 5 7
>
> The rows of 'A' correspond to the rows of 'Index'.
>
> Now, I am given another Index matrix which I call 'Index_hat'.
>
> Index_hat =
> 1 3
> 3 4
> 5 7
>
> Given this 'Index_hat' matrix I want to extract its corresponding rows in 'A', i.e.
>
> new_A =
> 20
> 40
> 50
>
> Any help much appreciated.
>
> all the best,
> kurtis
>

A(ismember(Index,Index_hat,'rows'))

Subject: extract rows given Index matrix

From: Kurt

Date: 9 Dec, 2010 21:51:05

Message: 3 of 3

thank you sean

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