Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: How to use two vectors as ordered pairs?
Date: Fri, 6 Apr 2012 22:02:17 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 23
Message-ID: <jlnp58$fbs$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1333749737 15740 172.30.248.47 (6 Apr 2012 22:02:17 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 6 Apr 2012 22:02:17 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1639175
Xref: news.mathworks.com comp.soft-sys.matlab:763626

Hi, 

I have the following problem and would appreciate if someone can help me.

r = a square matrix.
v= is another matrix with n rows and two columns.
k=the outcome, a vector.


I would like to use each row of v as indices for the get values in the matrix r and save them in a new vector k. For example:

r=[0 0 1 5;4 0 2 5;3 3 3 5;2 2 2 2]
v=[1 2; 2 3; 4 1;3 3];

k should be:

k=[0 2 2 3]

Some one can help me?

Thanks

P.