matrix values extraction
Jean-Damien Capdeville
jdcapdeville at gmail.com
Tue Jan 25 15:32:11 CET 2011
Dear all,
I'm looking to extract from a matrix "A" one value for each line. The column
positions of the value to extract would be given by a vector "c".
Here is an example:
A = [ 1 2 3 ; 4 5 6 ; 7 8 9 ; 10 11 12 ; 13 14 15 ]
c = [ 3 ; 1 ; 1 ; 2 ; 3 ]
How can I get the resulting vector [ 3 ; 4 ; 7 ; 11; 15 ] ?
I'm currently using a loop which is obviously a time expensive solution with
large matrix.
Any ideas to get it more efficiently?
Thanks,
Jean-Damien
More information about the users
mailing list