accessing multiple elements in a matrix matlab -


this question has answer here:

how can 1 access vector of elements different columns efficiently in matlab example:

a = [1 2 5 4      4 6 2 5      3 6 8 9      2 4 5 7      2 9 4 2] 

retrieve: (1, 1) (2,2) (3,1) (4,4) (5,3)

use sub2ind:

ret = [1 1;        2 2;        3 1;        4 4;        5 3];  a( sub2ind(size(a), ret(:,1), ret(:,2)) ) 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -