Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: Get matrix element at position specified by a vector

$
0
0
On 10/20/2012 3:40 PM, Merciadri Luca wrote:
...
...[given]...
> a = [[2 2]; [3 4]]
...
> b = [1 1]
...

> How can I get the element of a specified by vector b,...

 >> a=[2 3;4 5];
 >> b=[1 1];
 >> v=a(sub2ind(size(a),b))
v =
      2 2
 >>

--

Viewing all articles
Browse latest Browse all 19628

Trending Articles