1

Assume I have array A and B

B contain data that index array of Array A

( Example B(1,:) = [2 3] it mean that I want to access data of array A(2,3) )

I want to show the all data A that have in B

I try to code like this

A(B(:,1),B(:,2))

however when I try to run the program it seem wrong ( like I have B contain data 100 x 2 it should produce 100 results but it produces 200 instead)

1 Answer 1

1

You need sub2ind:

A(sub2ind(size(A),B(:,1),B(:,2)))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.